{
"sid": "as4ads68ds468486essf879g8de9sdg",
"details": {
"company_id": 1,
"sections": "details-all|settings-all|priv_profile-basic|access_profiles-basic|user_groups-basic",
"offset": 0,
"limit": 20,
"since_id": 0,
"filter_by": "details.surname",
"filter": "^[aA]",
"order_by": "details.surname",
"order": "asc"
}
}
I guess I could send this as something like the following (may need to URI Encode the string first, but just an example):
If you think about it, sending the parameters along in the URI is kind of a way of sending data to request data too. I understand though that this would be the more correct way of doing it.
I guess my biggest question is, is it ok to do your GETs and DELETEs like this (with the URI parameters) and then send JSON for POSTs and UPDATEs? Is that the industry accepted norm and standard way of doing a REST API which uses JSON as its primary format for sending around data?
Thanks again for the help and guidance!
Koot
http://my.url.com/users/123?sections=details-all,settings-all,priv_profile-basic <--For a specific user
http://my.url.com/users/?sections=details-all,settings-all,priv_profile-basic&offset=0&limit=20 <--For a listing of users
So, is something like this the best way to go:
POSThttp://my.url.com/users
data: json_code_goes_here
GET
http://my.url.com/users/123?sectionsÞtails-all,settings-all,priv_profile-basic <--For a specific user
http://my.url.com/users/?sectionsÞtails-all,settings-all,priv_profile-basic&offset=0&limit <--For a listing of users
UPDATEhttp://my.url.com/users/123
data: json_code_goes_here
DELETEhttp://my.url.com/users/123
A couple of alternatives to consider.1.) Instead of using application/json for post request consider using application/x-www-form-urlencoded on request for POST and PUT (not UPDATE, and also PATCH) if you data can be made simply enough. One benefit of this approach with POST is that it's the native format for HTML <form> submissions:
POSThttp://example.com/usersrequest: application/x-www-form-urlencodedresponse status code: XXXPUThttp://example.com/users/123request: application/x-www-form-urlencodedresponse status code: XXXPATCHhttp://example.com/users/123request: application/x-www-form-urlencodedresponse status code: XXX
2.) Consider offering a "query" resource (or whatever name you prefer) that the API client can use to create a query using POST and then the API client can GET the query
POSThttp://example.com/queriesrequest: application/x-www-form-urlencoded <-sections=tails-all,settings-all,priv_profile-basicresponse status code: XXXGETresponse: application/json -> { "name": "value", ... }response status code: XXXAND/ORPUThttp://example.com/queries/tails-settings-basicrequest: application/x-www-form-urlencoded <-sections=tails-all,settings-all,priv_profile-basicresponse status code: XXXGETresponse: application/json ->{ "name": "value", ... }response status code: XXXAgain, this are just alternatives to consider.
-Mike
--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group, send email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.