Skip to content

Instantly share code, notes, and snippets.

@midwire
Created July 10, 2014 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save midwire/1f560f8f1aa3dfec44ce to your computer and use it in GitHub Desktop.
Save midwire/1f560f8f1aa3dfec44ce to your computer and use it in GitHub Desktop.
Use curl for REST testing APIs
#!/usr/bin/env bash
# Use curl for REST testing apis
#
# curl params:
# i – show response headers
# H – pass request headers to the resource
# X – pass a HTTP method name
# d – pass in parameters enclosed in quotes; multiple parameters are separated by ‘&’
# curl -i -H "Accept: application/json" -X POST -d "firstName=james" http://192.168.0.165/persons/person
ACCEPT="application/json"
METHOD=`echo $1| tr [a-z] [A-Z]`
URL=$2
curl -i -H "Accept: ${ACCEPT}" -X $METHOD "${URL}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment