Skip to content

Instantly share code, notes, and snippets.

@srMarquinho
Last active March 7, 2018 12:41
Show Gist options
  • Save srMarquinho/84d08a1115df7a80a9de22d3d75dfe5b to your computer and use it in GitHub Desktop.
Save srMarquinho/84d08a1115df7a80a9de22d3d75dfe5b to your computer and use it in GitHub Desktop.
GET:
with JSON:
curl -i -H "Accept: application/json" -H "Content-Type: application/json" http://hostname/resource
as XML:
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET http://hostname/resource
curl -H "Accept: application/xml" "http://localhost:3040/api/org.xml"
curl -H "Accept: application/xml" -H "API_KEY: fgjfgjhfj68rvuIXy5XAlpRELmHKmOZNJeot62I3rePsnFAl15Wghjgs" "http://localhost:3040/api/org"
POST:
For posting data:
curl --data "param1=value1&param2=value2" http://hostname/resource
For file upload:
curl --form "fileupload=@filename.txt" http://hostname/resource
RESTful HTTP Post:
curl -X POST -d @filename http://hostname/resource
DELETE:
curl -X DELETE http://hostname/resource
For logging into a site (auth):
curl -d "username=admin&password=admin&submit=Login" --dump-header headers http://localhost/Login
curl -L -b headers http://localhost/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment