Skip to content

Instantly share code, notes, and snippets.

@saneshark
Created September 11, 2013 00:46
Show Gist options
  • Save saneshark/6517942 to your computer and use it in GitHub Desktop.
Save saneshark/6517942 to your computer and use it in GitHub Desktop.
curl / shell scripts for testing apis
#!/bin/bash
CURL='/usr/bin/curl'
MAINURL="https://api.myserver.com"
ACTION="users"
USERNAME="api_tester@myserver.com"
PASSWORD="secret"
PARAMS_TO_TEST="&company_id=1"
CURLARGS="-k"
PATH_TO_STORE="./output.xml"
EXECUTE=$MAINURL/$ACTION'?username='$USERNAME'&password='$PASSWORD$PARAMS_TO_TEST
echo "executing curl $EXECUTE"
$CURL $CURLARGS $EXECUTE > $PATH_TO_STORE
echo "output saved to file output.xml"
#!/bin/bash
CURL='/usr/bin/curl'
MAINURL="https://api.myserver.com/"
ACTION="users/create"
PARAMS_TO_TEST=""
CURLARGS="-k -d @post.xml -H 'Content-type: application/xml'"
PATH_TO_STORE="./output.xml"
EXECUTE=$MAINURL/$ACTION'?username='$USERNAME'&password='$PASSWORD$PARAMS_TO_TEST
echo "executing curl $EXECUTE"
$CURL $CURLARGS $EXECUTE > $PATH_TO_STORE
echo "output saved to file output.xml"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment