Skip to content

Instantly share code, notes, and snippets.

@Kif11
Created July 14, 2017 03:53
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 Kif11/5a959a632abb704c539edb81cf083812 to your computer and use it in GitHub Desktop.
Save Kif11/5a959a632abb704c539edb81cf083812 to your computer and use it in GitHub Desktop.
Example of HTTP request to Shotgun constructed in Bash
#!/usr/bin/env bash
function get_entity {
entity_type="$1"
if [[ -z $entity_type ]]; then
echo "Usage: sg_req [entity_type]"
return 1
fi
sg_site='eep' # Name of your shotgun site
url="https://${sg_site}.shotgunstudio.com/api3/json"
script_name="KEY_NAME_HERE"
api_key="KEY_HERE"
body="{
\"method_name\": \"read\",
\"params\": [
{
\"script_key\": \"${api_key}\",
\"script_name\": \"${script_name}\"
},
{
\"return_paging_info\": true,
\"return_fields\": [\"id\", \"name\"],
\"return_only\": \"active\",
\"paging\": {\"current_page\": 1, \"entities_per_page\": 500},
\"filters\": {\"logical_operator\": \"and\", \"conditions\": []},
\"api_return_image_urls\": true,
\"type\": \"${entity_type}\"
}
]}"
header='application/json; charset=utf-8'
curl --data "$body" "$url" --header "$header"
}
get_entity "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment