php - REST Resource vs Services -


i have created code make calls external api (that did not create). however, has been described 'service-centric', while rest apis 'resource-centric'.

what needs changed turn service based call? don't understand difference is. understand need use http verbs thought doing curl. possible curl?

the api have been passed contains bunch of resource urls example;

get http://api.privateservice.com/person?id=123

post http://api.privateservice.com/person/savedetails/123

think of resources nouns, ie objects or records in database. think of actions verbs, ie function calls.

the first example indeed resource-centric. it's getting resource of type person identified 123.

the second example not resource-centric because it's function call. rest , http establish conventions saving resource. in case need put resource's url, ie same url retrieved get.

so upload json (or whatever format) using:

put http://api.privateservice.com/person?id=123 

if passing in few attributes, not whole resource, there's standard that, patch:

patch http://api.privateservice.com/person?id=123 

btw it's bit cleaner use http://api.privateservice.com/people/123 url.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -