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:

Copy
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/
sagecrm/-/company/$schema

Returns the company schema.

http://SageCrmServer/sdata/crmj/
sagecrm/-/company('43')

Return the record for the company whose ID (comp_companyid field value) is 43.

http://SageCrmServer/sdata/crmj/
sagecrm/-/company?where=
comp_companyid eq '43'

http://SageCrmServer/sdata/crmj/
sagecrm/-/company(comp_companyid eq '43')

http://SageCrmServer/sdata/crmj/
sagecrm/-/company?where=comp_name
like 'A%' and comp_type eq 'customer%'

Returns the company records where the company name begins with A and the company type is customer.

http://SageCrmServer/sdata/crmj/
sagecrm/-/company?where=comp_companyid eq '43'&include=person,address,
phoneCollection,emailCollection

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/
sagecrm/-/company?where=comp_companyid eq '43'&include=Person

http://CRMserver/sdata/crmj/
sagecrm/-/vCompanySummary

Returns all records from the vCompanySummary user view.

http://CRMserver/sdata/crmj/
sagecrm/-/person?where=concat(pers_firstname, pers_lastname) eq 'William Agnew'

Returns the record for a person whose name is William Agnew.

http://CRMserver/sdata/crmj/
sagecrm/-/quoteitems?where=quit_productid ge 3 and quit_productid le 10

Returns quote records for products whose IDs fall between 3 and 10.

http://CRMserver/sdata/crmj/
sagecrm/-/quoteitems?where=quit_updateddate ge currenttimestamp()

Returns quote records that were updated on the current date or earlier.

http://CRMserver/sdata/crmj/
sagecrm/-/company('43')&SID=61546204736053

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:

Copy
<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>