Get Token API via curl
The 'Get Token' call returns a token that is used in all subsequent API calls. Since a token is short-lived, it will be necessary to repeat this process to obtain a new token when the previous token expires.
Issue the API call
To obtain the secure token, you make a 'get token' API call in which you supply the 'application_id' and 'application_key' generated when you set up API access. You must also supply an existing User value. The token value is then returned.
Below are examples of the API call using curl at unix command line for JSON (application/json), XML (application/xml), Form (application/x-www-form-urlencoded).
JSON example
JSON (Content-Type: application/json)
Here is an example of JSON request with JSON response:
Request:
curl --header "Content-Type:application/json" --header "Accept:application/json" -X POST --data '{"application_id":"ABC","application_key":"XYZ","user":"admin"}' https://yourinstance.com/api/get_token
Response:
{"token":"UClCUUKxUlkdbhE1cHLz3kyjbIZYVh9eB34A5Q21Y3FPqKGSJs","expires":"2014-02-17 18:46:08"}
XML example
XML (Content-Type: application/xml)
Here is an example of XML request with XML response:
Request:
curl --header "Content-Type:application/xml" --header "Accept:application/xml" -X POST --data '<request><application_id>ABC</application_id><application_key>XYZ</application_key><user>admin</user></request>' https://yourinstance.com/api/get_token
Response:
<?xml version="1.0" encoding="utf-8"?>
<response><token>UClCUUKxUlkdbhE1cHLz3kyjbIZYVh9eB34A5Q21Y3FPqKGSJs</token><expires>2014-02-17 18:46:08</expires></response>
Form example
Form (Content-Type: application/x-www-form-urlencoded)
Here is an example of Form request with XML response:
Request:
curl --header "Content-Type:application/x-www-form-urlencoded" -X POST --data "application_id=ABC&application_key=XYZ&user=admin" https://yourinstance.com/api/get_token
Response:
<?xml version="1.0" encoding="utf-8"?>
<response><token>UClCUUKxUlkdbhE1cHLz3kyjbIZYVh9eB34A5Q21Y3FPqKGSJs</token><expires>2014-02-17 18:46:08</expires></response>
Here is an example of Form request with JSON response:
Request:
curl --header "Content-Type:application/x-www-form-urlencoded" --header "Accept:application/json" -X POST --data "application_id=ABC&application_key=XYZ&user=admin" https://yourinstance.com/api/get_token
Response:
{"token":"UClCUUKxUlkdbhE1cHLz3kyjbIZYVh9eB34A5Q21Y3FPqKGSJs","expires":"2014-02-17 18:46:08"}