#!/bin/sh# README - one45 API cURL Example ######################################## 1. Save this api_curl_snippet.sh file on your mac/linux/unix computer# 2. In your terminal, navigate to folder where you saved this file# 3. In your terminal, execute command 'sh api_curl_snippet.sh'# 4. Enter your client key when prompted# 5. Enter your client secret when prompted# 6. Enter the URL for your sandbox site when prompted# 7. If all goes well, the JSON response should appear in the terminal######################################################################### First initialize all the neccessary variables to make one45 api requestecho"Enter your client key:"read client_key
echo"Enter your client secret:"read client_secret
echo"Enter your one45 site url (without 'http' or 'https'; e.g., 'uat.one45.com/api_sandbox_school_name'):"read school_base_url
# Requesting for an access_tokenecho"Requesting access_token..."response=$(curl request POST "https://$school_base_url/web/one45.php/public/api/v1/token/generate" --data "client_key=$client_key" --data "client_secret=$client_secret" -s)# Parse for the access token from responseaccess_token=$(expr "$response" : '.*"access_token":"\([^"]*\)"')# Requesting for Form resource (/api/v1/forms)"echo"Requesting Form resource (/api/v1/forms)..."forms_request_url="https://$school_base_url/web/one45.php/api/v1/forms?limit=2"# You will need to replace X with your access_token belowresponse=$(curl -s "$forms_request_url" -H "Accept: application/json" -H "Authorization: Bearer X")# Response of Form requestecho$response
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.