Closed AnneleenK closed 6 years ago
Your cheat sheet looks like it’s written by me, compared to this one https://github.com/tiimgreen/github-cheat-sheet or this one https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet! That makes it harder to remember this stuff the following weeks!
But glad you figured it out anyway Anneleen!
send a GET request - curl localhost:1901
inspect the headers - curl localhost:1901 --verbose
The output reads like this:
OPTIONS request - curl localhost:1901 --verbose --request OPTIONS
Delete request - curl -X "DELETE" localhost:1901
405 Method Not Allowed, means that the method (DELETE) is not supported.
send a HEAD request - curl -i -X HEAD localhost:1901
HEAD is the same as GET but without the body.
send a POST request - curl -i -X POST localhost:1901
POST is used to add something to a resource.
ending a POST request to / with an empty JSON object ({}) - curl localhost:1901 --verbose --request POST --data '{}'
422 Unprocessable Entity means that the request was valid, but there was something wrong with the data being sent to the server
send {"title":"Wonder Woman"} - curl localhost:1901 --verbose --request POST --data '{"title":"Wonder Woman"}'
Send an OPTIONS request to the newly created resource - curl localhost:1901/wonder-woman --verbose --request OPTIONS
send a HEAD request to /nonexistent-movie. - curl -i -X HEAD localhost:1901/nonexistent-movie
Send a PUT request to /wonder-woman and send {"title":"Wonder Woman","plot":"Diana fights a war"} - curl localhost:1901/wonder-woman --verbose --request PUT --data '{"title":"Wonder Woman","plot":"Diana fights a war"}'
To change only a few things, use PATCH
send a PATCH request to /wonder-woman and send {"description":"Diana leaves home to fight a
war."}. - curl localhost:1901/wonder-woman --verbose --request PATCH --data '{"description":"Diana leaves home to fight a war."}'
send a DELETE request to /wonder-woman. - curl -X "DELETE" localhost:1901/wonder-woman
The status code is in the 2xx range, which means the request was successful. 204 No Content specifically means that everything was OK, but there is no need for the server to send any data back.
Send a GET request to /wonder-woman. - curl localhost:1901/wonder-woman
410 Gone specifically means that there used to be something there, but it no longer exists.
asking for XML, by sending a GET request to / with an Accept header with the value application/xml. - curl localhost:1901 --header 'Accept: application/xml'
a GZipped resource, by sending a GET request to / with an Accept-Encoding header with the value gzip - curl localhost:1901 --verbose --request GET --header 'Accept-Encoding: gzip'
GZipped data is not readable at all for humans, but browsers and other user agents often deal with it automatically.
delete /evil-dead - curl -X "DELETE" localhost:1901/evil-dead - curl -X "DELETE" localhost:1901/evil-dead
sending a DELETE request to /evil-dead again, but this time use an Authorization
header with the value token 5b8822b29 - curl -X "DELETE" localhost:1901/evil-dead --header 'Authorization:token 5b8822b29'