开发者

what is the standard for creating a web REST API for adding new items

i have a order catalogue web site and i want to create a REST API so people can create their own apps and Add an Orde开发者_如何转开发r or Update an existing order:

Lets say an order has:

  1. OrderId
  2. Product
  3. Quantity
  4. ShippingType

So i need some API to allow someone to send in a new order (orderid would be blank as that would be in the response).

  1. How do you deal with passing in items like Product or Shipping type. These are tables in my db and are keyed off their own specific primary key id. Should the NewOrder API ask for a string name for these fields, should it ask for the id. If it asked for the ID, that would assume they would have to call the GiveMeProductList() method upfront (which gives you the name and id of all product as a dataset).

What is the standard for dealing with this?


Martin Fowler has a good post about the steps toward the glory of REST that you might find useful to come up with REST API.


The media type that I use for sending this information to the server can handle both scenarios, Id and Code/Name. If the user enters the product code manually then I send up the code, if the user asks to pick from a list then I provide the list and send back the Id.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜