api - How to pass an arbitrary number of parameters while adhering to REST principles -
i have database 3 tables: product
, category
, , xref_product_category
. business logic permits product associated arbitrary number of categories (bed, bath, kitchen, etc.). in terms of designing rest api, what's best way establish these relationships?
for reason i'm hesitant pass json array of category ids parameter, don't have reason not to. suppose other option make series of put
calls, passing single parameter each time. what's restful way establish multiple relationships this? should done in single api call, or in multiple calls?
in rest, phrase "arbitrary number of parameters" means "representation".
the parameters whole combined payload content represent resource.
so firstly define schema payload, , you'll have media type can used represent it. document schema , tell people use api can post or put content define product , arbitrary relationships other resources.
then define uri product
resource , how clients navigate cool (entry-point) uri it.
Comments
Post a Comment