Reputation: 135
I'm working on service that collects prices from third-party online shop. I use RESTful API to add new product id and get price by id.
To add new product:
POST /product/12345
(parses product page and stores price to db)
To update stored price:
PUT /product/12345
(parses product page and updates price in db)
To get price:
GET /product/12345
(return price from db if data exists)
My question is am I doing it right way (especially with POST verb)?
Upvotes: 1
Views: 164
Reputation: 85
Normally the API calls for the Post : Data will not be placed on the url, which can be mentioned like below
To add new product: POST /product/new
Thanks, SVN
Upvotes: 4
Reputation:
To add a new product
, POST
to the collection resource /product
:
POST /product/
The server will assign an ID to the new Product and return it.
201 Created
Location: http://example.com/product/9876
Edit:
If you already know the ID, create the product using PUT
:
PUT /product/9876
Upvotes: 2