HTTP request URL
To access an entity, custom table, or user view via SData, you need to make an HTTP request in the format that is specific to your Sage CRM environment. The response is always XML.
Your HTTP request should have the following format:
http://<Server>/sdata/<InstallName>j/sagecrm/-/<Target>
Where:
- <Server>. Is the name of the computer on which Sage CRM is installed.
- <InstallName>. Is the name of the Sage CRM install (this is crm by default). Make sure to append j after the install name as shown in the HTTP request format above.
- <Target>. Is the name of the entity, custom table, or view you want to access.
The following table provides sample HTTP requests and their descriptions.
HTTP request |
Description |
---|---|
http://SageCrmServer/sdata/crmj/ |
Returns the company schema. |
http://SageCrmServer/sdata/crmj/ |
Return the record for the company whose ID (comp_companyid field value) is 43. |
http://SageCrmServer/sdata/crmj/ |
|
http://SageCrmServer/sdata/crmj/ |
|
http://SageCrmServer/sdata/crmj/ |
Returns the company records where the company name begins with A and the company type is customer. |
http://SageCrmServer/sdata/crmj/ |
Return the record for the company whose ID (comp_companyid field value) is 43. The response includes the name, address, phone, and email of the primary person associated with the company.
|
http://CRMserver/sdata/crmj/ |
|
http://CRMserver/sdata/crmj/ |
Returns all records from the vCompanySummary user view. |
http://CRMserver/sdata/crmj/ |
Returns the record for a person whose name is William Agnew. |
http://CRMserver/sdata/crmj/ |
Returns quote records for products whose IDs fall between 3 and 10. |
http://CRMserver/sdata/crmj/ |
Returns quote records that were updated on the current date or earlier. |
http://CRMserver/sdata/crmj/ |
Authenticates the user by using session ID (SID) and returns the record for the company whose ID (comp_companyid field value) is 43. You can use session ID (SID) in the SData URL as an alternative authentication mechamism in SData requests. |
You can also use fast SData requests for AJAX in Custom Content and OnChange scripts, for example:
<script>
function GetKeyValue(querystringname) {
var strPath = window.location.search.substring(1);
var arrayKeys = strPath.split("&");
for (var i = 0; i < arrayKeys.length; i++) {
var arrayValue = arrayKeys[i].split("=");
if (arrayValue[0].toLowerCase() == querystringname.toLowerCase()) {
return arrayValue[1];
}
}
return "";
}
window.alert("start:" + GetKeyValue("SID"));
XmlHttp = new XMLHttpRequest();
var strURL = "http://richardsj-lt/sdata/crm71j/sagecrm/-/company?where=comp_companyid in ('43', '45')&SID=" + GetKeyValue("SID");
XmlHttp.open('GET', strURL, false);
window.alert("open");
XmlHttp.send(null);
window.alert("send");
var strHtml = XmlHttp.responseText;
XmlHttp = null; // always clear the XmlHttp object when you are done to avoid memory leaks
window.alert("test:" + strHtml);
window.alert("end");
</script>