Skip to content

Instantly share code, notes, and snippets.

@btopro
Last active August 29, 2015 14:04
Show Gist options
  • Save btopro/1181cd160afc3370e88c to your computer and use it in GitHub Desktop.
Save btopro/1181cd160afc3370e88c to your computer and use it in GitHub Desktop.
Hands on RESTful webservices

http://rest7.btopro.net username: restws_test password: test

Either use terminal (recommended) or POSTMAN -- http://www.getpostman.com/ (good for simple commands)

C - create R - read U - update D - delete

"Q" -- Read also can be used to query multiple resources

this is used for most calls

site.com/{entity_type}/{id}.{format}

Some examples to try: note for this example you obviously can destroy content on the site and kind of do whatever you want.

READ

return the user 4 resource as json

curl http://restws_test:test@rest7.btopro.net/user/4.json

return node 1 as xml

curl http://restws_test:test@rest7.btopro.net/node/1.xml

CREATE

curl -X POST -H Content-Type:application/json -H Cache-Control:no-cache -d '{"title":"stuff","type":"page","language":"und","status":"1","author":"4"}' http://restws_test:test@rest7.btopro.net/node

UPDATE

curl -X PUT -H Content-Type:application/json -d '{"title":"stuff","body":{"format":"plain_text","value":"stuff","summary":"stuff"},"type":"page","author":"4","nid":"7"}' http://restws_test:test@rest7.btopro.net/node/7

DELETE

curl -X DELETE -H Content-Type:application/json http://restws_test:test@rest7.btopro.net/node/5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment