Returns the subject, description, start date/time and activity ID for phone calls regarding an account. This example gets the phone calls regarding the Fourth Coffee account (accountid = b6a19cdd-88df-e311-b8e5-6c3be5a8b200).
curl -X GET https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/phonecalls \
-H "Accept: application/json" \
-H "OData-MaxVersion: 4.0" \
-H "OData-Version: 4.0" \
-d "$filter=_regardingobjectid_value eq b6a19cdd-88df-e311-b8e5-6c3be5a8b200" \
-d "$select=subject,description,actualstart,activityid" \
-H "Authorization: Bearer DYNAMICS_CRM_ACCESS_TOKEN"
Use ChilkatAx-9.5.0-win32.pkg
Procedure Test
Handle hoRest
Boolean iSuccess
Boolean iBTls
Integer iPort
Boolean iBAutoReconnect
Variant vSbResponseBody
Handle hoSbResponseBody
Integer iRespStatusCode
Handle hoJsonResponse
Integer i
Integer iCount_i
String sOdataContext
String sOdataEtag
String sSubject
String sDescription
String sActualstart
String sActivityid
String sTemp1
Integer iTemp1
Get Create (RefClass(cComChilkatRest)) To hoRest
If (Not(IsComObjectCreated(hoRest))) Begin
Send CreateComObject of hoRest
End
// URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/phonecalls
Move True To iBTls
Move 443 To iPort
Move True To iBAutoReconnect
Get ComConnect Of hoRest "my-dynamics-domain.api.crm.dynamics.com" iPort iBTls iBAutoReconnect To iSuccess
If (iSuccess <> True) Begin
Get ComConnectFailReason Of hoRest To iTemp1
Showln "ConnectFailReason: " iTemp1
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComAddQueryParam Of hoRest "$filter" "_regardingobjectid_value eq b6a19cdd-88df-e311-b8e5-6c3be5a8b200" To iSuccess
Get ComAddQueryParam Of hoRest "$select" "subject,description,actualstart,activityid" To iSuccess
Get ComAddHeader Of hoRest "OData-MaxVersion" "4.0" To iSuccess
Get ComAddHeader Of hoRest "Accept" "application/json" To iSuccess
Get ComAddHeader Of hoRest "OData-Version" "4.0" To iSuccess
Get ComAddHeader Of hoRest "Authorization" "Bearer DYNAMICS_CRM_ACCESS_TOKEN" To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComFullRequestNoBodySb Of hoRest "GET" "/api/data/v9.0/phonecalls" vSbResponseBody To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComResponseStatusCode Of hoRest To iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Status Code = " iRespStatusCode
Showln "Response Header:"
Get ComResponseHeader Of hoRest To sTemp1
Showln sTemp1
Showln "Response Body:"
Get ComGetAsString Of hoSbResponseBody To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse
If (Not(IsComObjectCreated(hoJsonResponse))) Begin
Send CreateComObject of hoJsonResponse
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJsonResponse vSbResponseBody To iSuccess
Get ComStringOf Of hoJsonResponse '"@odata.context"' To sOdataContext
Move 0 To i
Get ComSizeOfArray Of hoJsonResponse "value" To iCount_i
While (i < iCount_i)
Set ComI Of hoJsonResponse To i
Get ComStringOf Of hoJsonResponse 'value[i]."@odata.etag"' To sOdataEtag
Get ComStringOf Of hoJsonResponse "value[i].subject" To sSubject
Get ComStringOf Of hoJsonResponse "value[i].description" To sDescription
Get ComStringOf Of hoJsonResponse "value[i].actualstart" To sActualstart
Get ComStringOf Of hoJsonResponse "value[i].activityid" To sActivityid
Move i + 1 To i
Loop
End_Procedure
{
"@odata.context": "https://mydomain.api.crm.dynamics.com/api/data/v9.0/$metadata#phonecalls(subject,description,actualstart,activityid)",
"value": [
{
"@odata.etag": "W/\"1818469\"",
"subject": "Discussed coffee bean pricing.",
"description": "Discussed coffee bean pricing.",
"actualstart": "2018-04-29T11:56:21Z",
"activityid": "098af854-a44b-e811-a955-000d3a1ca612"
}
]
}