All data interactions with CAPS-Xt happen through its /Data end point. When calling the /Data end point, a GET or a POST request can be performed; depending on your method for calling the service and what type or amount of data you're passing in, one of the two methods will be preferred.
In plain terms, any time a CAPS-Xt call is made within a “URL to XML” property of a web part (such as a CorasWorks Basic Grid), a GET request is being made. This means all of the parameters are specified in the URL itself as query string parameters.
By contrast, when working with JavaScript, it is usually preferred to use a POST request. While a GET request can be made via AJAX call, a POST request provides flexibility with the available data parameters without having to be concerned with length or URL encoding.
A simple GET request looks like this:
http://HostName/site/_vti_bin/CorasWorks/capsxt.svc/Data?configName=MyConnectionName&sqlParams=
The same call as a POST in jQuery looks like:
$.ajax({
type:
'POST',
url:
'../_vti_bin/CorasWorks/capsxt.svc/Data',
data:
JSON.stringify({
configOptions:
{
configName:
'MyConnectionName',
sqlParams: ''
}
}),
dataType: 'json',
contentType: "application/json; charset=utf-8"
});
NOTE: The “configName” and “sqlParams” parameters are always required and case-sensitive. As they are required, they always need to be supplied even if blank in the case of "sqlParams"; a blank "configName" is never allowed because it is the "configName" that maps to the Connection Name, which tells the service which connection to execute.
In addition to those required parameters, there are three optional parameters that can be used when calling CAPS-Xt, all of which are also case-sensitive:
• format: The supported options are XML (default), JSON, and HTML; this parameter is equivalent to the “OutputType” parameter in CAPS.
• xslLocation: This parameter allows for the setting or overriding of the default XSLT Stylesheet at runtime, and is similar to the XsltLocation parameter in CAPS.
• ContentDisposition: This parameter allows for setting the ContentDisposition Response Header, which can be used to trigger the downloading of a file on the client if the response of the service call is a dynamically generated document; this parameter is equivalent to the CAPS parameter of the same name.
For additional examples and use cases with CAPS-Xt, check out the CAPS-Xt section of the CAPS Learning Center.