Created
July 14, 2017 03:53
-
-
Save Kif11/5a959a632abb704c539edb81cf083812 to your computer and use it in GitHub Desktop.
Example of HTTP request to Shotgun constructed in Bash
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 | |
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