Terra Dotta Software API Documentation
Back to Terra Dotta Software API Documentation Return to Public Site
Top
Top
Using our original call:
(the following XML packet is formatted for readability)
We can modify the call to return the data in SOAP format by specifying
(the following XML packet is formatted for readability)
We can modify the call to return the data in JSON format by specifying
(the following JSON packet is formatted for readability)
The data returned using JSON encoding is wrapped within the callback function,
Example 1: Following is an example of using ColdFusion to call the API and returning the data in a SOAP envelope:
Run Example 1 Top
(if your installation does not have any data, this example will not return anything)
Back to Terra Dotta Software API Documentation Top
getProgramTerms
Returns a list of all available locations or locations specific to a program.URL
http://{site root}/piapi/index.cfm?callName=getProgramTerms
The value for {site root} would represent your installation URL. The values returned from this function are in the following table.
- Table 1: Input arguments for getProgramTerms
- Table 2: Return values for getProgramTerms
- Example 1: Calling getProgramTerms with ColdFusion
Top
Standard Input Parameters (jump to call specific input arguments) | |||
---|---|---|---|
Argument | Type | Required | Meaning |
ResponseEncoding | String | Optional | The data format to be returned by the API call. The value for ResponseEncoding can be one of the following values:
(case insensitive) |
CallBack | Boolean | Optional | Used with JSON only to specify if a callback function will be used or not. |
CallBackName | String | Optional | Used with JSON only to specify the callback function to use. |
Call-specific Input Parameters (jump to standard input arguments) | |||
Argument | Type | Required | Meaning |
program_id | Integer | Required | Program ID for which to gather terms for. |
Top
Return Value | Type | Meaning |
---|---|---|
program_term | String | Program term name. |
Using our original call:
http://{site root}/piapi/index.cfm?callName=getProgramTerms&ResponseEncoding=xml&Program_ID=10001
We would receive a packet of data in XML format (the default), that might resemble the following:
(the following XML packet is formatted for readability)
<terms>
<recordcount>3</recordcount>
<term>
<program_term>Academic Year</program_term>
</term>
<term>
<program_term>Fall</program_term>
</term>
<term>
<program_term>Spring</program_term>
</term>
</terms>
<recordcount>3</recordcount>
<term>
<program_term>Academic Year</program_term>
</term>
<term>
<program_term>Fall</program_term>
</term>
<term>
<program_term>Spring</program_term>
</term>
</terms>
We can modify the call to return the data in SOAP format by specifying
ResponseEncoding=SOAP
:
http://{site root}/piapi/index.cfm?callName=getProgramTerms&ResponseEncoding=SOAP&Program_ID=10001
We would receive a packet of XML wrapped within a SOAP envelope that might resemble the following:
(the following XML packet is formatted for readability)
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<terms>
<recordcount>3</recordcount>
<term>
<program_term>Academic Year</program_term>
</term>
<term>
<program_term>Fall</program_term>
</term>
<term>
<program_term>Spring</program_term>
</term>
</terms>
</soapenv:Body>
</soapenv:Envelope>
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<terms>
<recordcount>3</recordcount>
<term>
<program_term>Academic Year</program_term>
</term>
<term>
<program_term>Fall</program_term>
</term>
<term>
<program_term>Spring</program_term>
</term>
</terms>
</soapenv:Body>
</soapenv:Envelope>
We can modify the call to return the data in JSON format by specifying
ResponseEncoding=JSON
:
http://{site root}/piapi/index.cfm?callName=getProgramTerms&ResponseEncoding=JSON&Program_ID=10001
We would receive a JSON-encoded packet:
(the following JSON packet is formatted for readability)
_cb_getProgramTerms(
{
"recordcount":3,
"columnlist":"program_term",
"data":{
"program_term":[
"Academic Year",
"Fall",
"Spring"
]
}
);
{
"recordcount":3,
"columnlist":"program_term",
"data":{
"program_term":[
"Academic Year",
"Fall",
"Spring"
]
}
);
The data returned using JSON encoding is wrapped within the callback function,
_cb_getProgramterms()
.
By default, all JSON calls are returned within a callback wrapper function in form of:
_cb_callName()
Where callName
represents the name of the function you originally called.
To override this, you can specify the callBackName
argument, as in:
http://{site root}/piapi/index.cfm?callName=getRandomTestimonial&Program_ID=10001&ResponseEncoding=JSON&callBackName=MyCallBackFunction
This call would return the JSON packet wrapped within the callback function, MyCallBackFunction
, as in:
_cb_MyCallBackFunction(...json-encoded data...)
In your custom pages, you would then create a corresponding function to handle this custom callback function:
<script language="JavaScript" type="text/javascript">
<!--
// <![CDATA[
function _cb_MyCallBackFunction(data)
{
// put additional routines here
}
// ]]>
//-->
</script>
If you would like to receive the data without a callback function, you can use the argument <!--
// <![CDATA[
function _cb_MyCallBackFunction(data)
{
// put additional routines here
}
// ]]>
//-->
</script>
callBack
to override this. Specifying a value of false
for the callBack
argument returns the data without the callback function, as in:
http://{site root}/piapi/index.cfm?callName=getProgramterms&ResponseEncoding=JSON&Program_ID=10001&callBack=false
Note: specifying callBack=true
is implied and is unnecessary for returning JSON data with a callback function.
Example 1: Following is an example of using ColdFusion to call the API and returning the data in a SOAP envelope:
Run Example 1 Top
(if your installation does not have any data, this example will not return anything)
<!---// local variables //--->
<cfparam name="responsePacket" default="[ no response ]" />
<cfparam name="url.program_id" default="10001" />
<!---// connect to the API (GET or POST) //--->
<cfhttp result="httpCall" method="post" url="#REQUEST.CurrentAccount.AccountURL()#piapi/index.cfm">
<cfhttpparam name="callName" type="url" value="getProgramTerms" />
<cfhttpparam name="ResponseEncoding" type="url" value="SOAP" />
<cfhttpparam name="Program_id" type="url" value="#url.program_id#" />
</cfhttp>
<!---// ensure the response is in XML format //--->
<cfif isXml(httpCall.fileContent)>
<!---// parse response //--->
<cfset responsePacket = xmlParse(httpCall.fileContent) />
<!---// check to see if an error was thrown //--->
<cfset err = xmlSearch(responsePacket, "//extrainfo") />
<!---// an error was thrown //--->
<cfif isArray(err) and not arrayIsEmpty(err)>
<!---// throw error //--->
<cfthrow message="#err[1].xmlText#" />
<cfabort />
</cfif>
<cfelse>
<!---// additional error checking //--->
</cfif>
<!---// additional code goes here //--->
<h2>Output for 'responsePacket':</h2>
<cfdump VAR="#responsePacket#" />
For additional techniques, be sure to visit the other program calls within these documentation pages.
<cfparam name="responsePacket" default="[ no response ]" />
<cfparam name="url.program_id" default="10001" />
<!---// connect to the API (GET or POST) //--->
<cfhttp result="httpCall" method="post" url="#REQUEST.CurrentAccount.AccountURL()#piapi/index.cfm">
<cfhttpparam name="callName" type="url" value="getProgramTerms" />
<cfhttpparam name="ResponseEncoding" type="url" value="SOAP" />
<cfhttpparam name="Program_id" type="url" value="#url.program_id#" />
</cfhttp>
<!---// ensure the response is in XML format //--->
<cfif isXml(httpCall.fileContent)>
<!---// parse response //--->
<cfset responsePacket = xmlParse(httpCall.fileContent) />
<!---// check to see if an error was thrown //--->
<cfset err = xmlSearch(responsePacket, "//extrainfo") />
<!---// an error was thrown //--->
<cfif isArray(err) and not arrayIsEmpty(err)>
<!---// throw error //--->
<cfthrow message="#err[1].xmlText#" />
<cfabort />
</cfif>
<cfelse>
<!---// additional error checking //--->
</cfif>
<!---// additional code goes here //--->
<h2>Output for 'responsePacket':</h2>
<cfdump VAR="#responsePacket#" />
Back to Terra Dotta Software API Documentation Top