Created
July 10, 2014 14:00
-
-
Save midwire/1f560f8f1aa3dfec44ce to your computer and use it in GitHub Desktop.
Use curl for REST testing APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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