Returns selected data for all cases (incidents) specific to the Fourth Coffee account (b6a19cdd-88df-e311-b8e5-6c3be5a8b200)
curl -X GET https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/incidents \
-H "Accept: application/json" \
-H "OData-MaxVersion: 4.0" \
-H "OData-Version: 4.0" \
-d "$select=title,prioritycode,severitycode,ticketnumber,createdon,followupby,resolveby" \
-d "$expand=customerid_account($select=accountid,name)" \
-d "$filter=customerid_account/accountid eq b6a19cdd-88df-e311-b8e5-6c3be5a8b200" \
-H "Authorization: Bearer DYNAMICS_CRM_ACCESS_TOKEN"
LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJsonResponse
LOCAL i
LOCAL lnCount_i
LOCAL lcOdataContext
LOCAL lcOdataEtag
LOCAL lcTitle
LOCAL lnPrioritycode
LOCAL lnSeveritycode
LOCAL lcTicketnumber
LOCAL lcCreatedon
LOCAL lcFollowupby
LOCAL lcResolveby
LOCAL lcIncidentid
LOCAL lcCustomerid_accountAccountid
LOCAL lcCustomerid_accountName
loRest = CreateObject('Chilkat_9_5_0.Rest')
* URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/incidents
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("my-dynamics-domain.api.crm.dynamics.com",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
? loRest.LastErrorText
RELEASE loRest
CANCEL
ENDIF
loRest.AddQueryParam("$select","title,prioritycode,severitycode,ticketnumber,createdon,followupby,resolveby")
loRest.AddQueryParam("$expand","customerid_account($select=accountid,name)")
loRest.AddQueryParam("$filter","customerid_account/accountid eq b6a19cdd-88df-e311-b8e5-6c3be5a8b200")
loRest.AddHeader("OData-MaxVersion","4.0")
loRest.AddHeader("Accept","application/json")
loRest.AddHeader("OData-Version","4.0")
loRest.AddHeader("Authorization","Bearer DYNAMICS_CRM_ACCESS_TOKEN")
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/api/data/v9.0/incidents",loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loSbResponseBody
CANCEL
ENDIF
lnRespStatusCode = loRest.ResponseStatusCode
IF (lnRespStatusCode >= 400) THEN
? "Response Status Code = " + STR(lnRespStatusCode)
? "Response Header:"
? loRest.ResponseHeader
? "Response Body:"
? loSbResponseBody.GetAsString()
RELEASE loRest
RELEASE loSbResponseBody
CANCEL
ENDIF
loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.LoadSb(loSbResponseBody)
lcOdataContext = loJsonResponse.StringOf('"@odata.context"')
i = 0
lnCount_i = loJsonResponse.SizeOfArray("value")
DO WHILE i < lnCount_i
loJsonResponse.I = i
lcOdataEtag = loJsonResponse.StringOf('value[i]."@odata.etag"')
lcTitle = loJsonResponse.StringOf("value[i].title")
lnPrioritycode = loJsonResponse.IntOf("value[i].prioritycode")
lnSeveritycode = loJsonResponse.IntOf("value[i].severitycode")
lcTicketnumber = loJsonResponse.StringOf("value[i].ticketnumber")
lcCreatedon = loJsonResponse.StringOf("value[i].createdon")
lcFollowupby = loJsonResponse.StringOf("value[i].followupby")
lcResolveby = loJsonResponse.StringOf("value[i].resolveby")
lcIncidentid = loJsonResponse.StringOf("value[i].incidentid")
lcCustomerid_accountAccountid = loJsonResponse.StringOf("value[i].customerid_account.accountid")
lcCustomerid_accountName = loJsonResponse.StringOf("value[i].customerid_account.name")
i = i + 1
ENDDO
RELEASE loRest
RELEASE loSbResponseBody
RELEASE loJsonResponse
{
"@odata.context": "https://mydomain.api.crm.dynamics.com/api/data/v9.0/$metadata#incidents(title,prioritycode,severitycode,ticketnumber,createdon,followupby,resolveby,customerid_account(accountid,name))",
"value": [
{
"@odata.etag": "W/\"1161596\"",
"title": "Faulty product catalog",
"prioritycode": 2,
"severitycode": 1,
"ticketnumber": "CAS-01220-S1K8F4",
"createdon": "2017-01-20T22:50:47Z",
"followupby": "2015-06-04T16:15:42Z",
"resolveby": "2015-06-05T16:15:42Z",
"incidentid": "c49e62a8-90df-e311-9565-a45d36fc5fe8",
"customerid_account": {
"accountid": "b6a19cdd-88df-e311-b8e5-6c3be5a8b200",
"name": "Fourth Coffee"
}
},
{
"@odata.etag": "W/\"1161597\"",
"title": "Maintenance information for Desktop PCs.",
"prioritycode": 3,
"severitycode": 1,
"ticketnumber": "CAS-01226-D5F0K2",
"createdon": "2017-01-20T22:50:54Z",
"followupby": "2015-06-04T23:15:46Z",
"resolveby": "2015-06-05T23:15:46Z",
"incidentid": "d09e62a8-90df-e311-9565-a45d36fc5fe8",
"customerid_account": {
"accountid": "b6a19cdd-88df-e311-b8e5-6c3be5a8b200",
"name": "Fourth Coffee"
}
},
{
"@odata.etag": "W/\"1161598\"",
"title": "Need service feature question",
"prioritycode": 1,
"severitycode": 1,
"ticketnumber": "CAS-01232-S7L0X4",
"createdon": "2017-01-20T22:50:57Z",
"followupby": "2015-06-04T16:15:49Z",
"resolveby": "2015-06-05T16:15:49Z",
"incidentid": "dc9e62a8-90df-e311-9565-a45d36fc5fe8",
"customerid_account": {
"accountid": "b6a19cdd-88df-e311-b8e5-6c3be5a8b200",
"name": "Fourth Coffee"
}
},
{
"@odata.etag": "W/\"1161599\"",
"title": "Product catalog requested",
"prioritycode": 3,
"severitycode": 1,
"ticketnumber": "CAS-01237-H0T7F2",
"createdon": "2017-01-20T22:50:58Z",
"followupby": null,
"resolveby": null,
"incidentid": "e69e62a8-90df-e311-9565-a45d36fc5fe8",
"customerid_account": {
"accountid": "b6a19cdd-88df-e311-b8e5-6c3be5a8b200",
"name": "Fourth Coffee"
}
},
{
"@odata.etag": "W/\"1161600\"",
"title": "Product service time inquiry",
"prioritycode": 1,
"severitycode": 1,
"ticketnumber": "CAS-01249-V5V2X3",
"createdon": "2017-01-20T22:51:04Z",
"followupby": null,
"resolveby": null,
"incidentid": "fe9e62a8-90df-e311-9565-a45d36fc5fe8",
"customerid_account": {
"accountid": "b6a19cdd-88df-e311-b8e5-6c3be5a8b200",
"name": "Fourth Coffee"
}
},
{
"@odata.etag": "W/\"1161601\"",
"title": "Service required",
"prioritycode": 1,
"severitycode": 1,
"ticketnumber": "CAS-01256-G9B1B1",
"createdon": "2017-01-20T22:51:06Z",
"followupby": "2015-06-04T16:16:06Z",
"resolveby": "2015-06-05T16:16:06Z",
"incidentid": "0c9f62a8-90df-e311-9565-a45d36fc5fe8",
"customerid_account": {
"accountid": "b6a19cdd-88df-e311-b8e5-6c3be5a8b200",
"name": "Fourth Coffee"
}
},
{
"@odata.etag": "W/\"1161602\"",
"title": "Shipping time information resend",
"prioritycode": 3,
"severitycode": 1,
"ticketnumber": "CAS-01261-N0C8H9",
"createdon": "2017-01-20T22:51:13Z",
"followupby": "2015-06-04T16:16:09Z",
"resolveby": "2015-06-05T16:16:10Z",
"incidentid": "169f62a8-90df-e311-9565-a45d36fc5fe8",
"customerid_account": {
"accountid": "b6a19cdd-88df-e311-b8e5-6c3be5a8b200",
"name": "Fourth Coffee"
}
}
]
}