notes/curl_notes.txt

36 lines
1.8 KiB
Text

Very Simple GET request:
curl http://localhost:3000/maria_database
Simple JSON POST request:
curl -X POST http://localhost:3000/maria_database -H "Content-Type: application/json" -d '{"task": "DONE IN CURL"}'
Simple JSON DELETE request:
curl -X DELETE http://localhost:3000/maria_database -H "Content-Type: application/json" -d '{"deletedItem": "DONE IN CURL"}'
Simple JSON PUT request:
curl -X PUT http://localhost:3000/maria_database -H "Content-Type: application/json" -d '{"updated": "WE DID THIS IN CURL AGAIN", "previous": "DONE IN CURL"}'
########Authentication of JSON web Tokens using Curl ################
#See web dev simplified's web tutorial on basic JSON web token authorization
# First login using a post request:
curl -X POST http://localhost:3000/login -H "Content-Type: application/json" -d '{"username": "Kyle"}'
# then have it return a JWT, which you can paste into the Bearer section of a GET request like so:
<<<<<<< HEAD
curl -H 'Accept: application/json' -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSmltIiwiaWF0IjoxNjI5ODkyNTU1fQ.yMsrbX_c-vAXRMMYe5OFRWfg95zk0J2BBsv0zjcy4gU" http://localhost:3000/posts
=======
curl -H 'Accept: application/json' -H "Authorization: Bearer "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSmltIiwiaWF0IjoxNjI5ODkyNTU1fQ.yMsrbX_c-vAXRMMYe5OFRWfg95zk0J2BBsv0zjcy4gU" http://localhost:3000/posts
>>>>>>> 95f75b948d7df9af11c31531df2f9f69130561c3
################ OTHER BASIC USES OF CURL ################
# Simply write the html output of a website to an html file for offline browsing
curl http://mywebsite.com >> mywebsite.html
# If for whatever reason you get a Binary (and a warning), it means the site was compressed. to decompress, simply write:
curl --compressed http://mycompressedwebsite.com >> mydecompressedhtml.html