Running a template |
To run a template, POST to the following address:
https://acme.api.telogis.com/execute? template=<template id or name> &<user input1>=<value 1> &...<user input n>=<value n>
The template runs in synchronous mode by default. For templates that require longer processing time, you can run in asynchronous mode by setting the PollingMode query parameter when you submit the request.
This topic contains the following sections:
The query parameters of the URL provide the values for any variables declared in the User section of the template. When passing parameters, follow these rules:
No spaces between the variable name, equals sign, and value.
No quotes around the value portion of a parameter.
Ampersand (&) separators between parameter variable/value pairs.
...&ReportStart=2012-10-10&ReportEnd=2012-10-12
If the template is a create or update template, the body of the request will contain the input data.
The possible response status codes when running a template in synchronous mode are:
For synchronous mode (default), the response body varies according to the type of template.
For Retrieve templates, the response (on success) will be the data corresponding to the output section of the template. For example:
label,Number,Street,CityName,State,Zip,Lat,Lon Marker 1,654,S Raymond Rd,La Grange,Texas,78945,30,-97 Marker 2,0,,,,,30,173.000021457673 Marker 4,1,,Killeen,Texas,76542,31,-97.7000002682209
For Create, Update, and Delete templates, the response (on success) indicates the number of failed, created, updated, and deleted changes, and it indicates the Commit mode of the template. For example:
{ "Commit":true, "Failed": 0, "Created": 3, "Deleted": 0, "Updated": 0 }
While you may have received a 200 indicating that the template completed successfully, it is possible for individual entries to fail. If that occurs, then the JSON response body includes information about the failed records.
For example:
{ "Parse Failed Records": [ { "Reason": "Cannot parse color Blue as it is not formatted as a hexadecimal RGB color", "InputRow": 2, "Row": "Category 1,Blue", "errorInfo": [ { "errorText": "Cannot parse color Blue as it is not formatted as a hexadecimal RGB color", "errorCode": "3.1.10" } ] } ], "Commit": true, "Failed": 1, "Created": 0, "Deleted": 0, "Updated": 2 }
Tip |
---|
See Status codes and responses for more information about the JSON response body. |
The query string parameter PollingMode lets you run queries in the background (asynchronously) when you have long-running input and retrieve templates. PollingMode can be set to the following values:
Sets template processing to asynchronous mode. When you submit a request, the JSON response provides a URL to check for status updates.
Sets template processing to asynchronous mode and adds additional time to the polling interval. When you submit a request, the sytem returns the redirect count along with the URL to check for status updates.
Use this option if your client framework will timeout after a set number of redirects.
This setting disables asynchronous polling and runs the request in the default synchronous mode.
The possible response status codes when running a template in asynchronous mode are:
When you receive a 202 response, the return value gives the web page for requesting status updates. For example, if the request includes the query string &PollingMode=Async you get a response like the following:
{"ResultUrl":"https://acme.api.telogis.com/runner/MTM5ZWE3MTYtNjM5ZS00ZGY4LTk1MjgtODE0MTE5NzU4OGJmfGxhLWludGVncmF0ZTMudGVsb2dpcy5sb2NhbDo4MQ=="}
After the request is submitted, the following responses are returned during processing:
{ "Status": "Preparing" }
{ "Status": "Retrieving" }
When the request completes, TDE returns the results.
If the request includes the query string &PollingMode=Redirect202, the response also includes the redirect count:
{ "RedirectCount": 1 "ResultUrl":"https://acme.api.telogis.com/runner/MTM5ZWE3MTYtNjM5ZS00ZGY4LTk1MjgtODE0MTE5NzU4OGJmfGxhLWludGVncmF0ZTMudGVsb2dpcy5sb2NhbDo4MQ==" }
To get a status update or the result string, make a GET request to the URL provided. Possible response status codes when requesting to this URL are: