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"
func chilkatTest() {
let rest = CkoRest()
var success: Bool
// URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/phonecalls
var bTls: Bool = true
var port: Int = 443
var bAutoReconnect: Bool = true
success = rest.Connect("my-dynamics-domain.api.crm.dynamics.com", port: port, tls: bTls, autoReconnect: bAutoReconnect)
if success != true {
print("ConnectFailReason: \(rest.ConnectFailReason.intValue)")
print("\(rest.LastErrorText)")
return
}
rest.AddQueryParam("$filter", value: "_regardingobjectid_value eq b6a19cdd-88df-e311-b8e5-6c3be5a8b200")
rest.AddQueryParam("$select", value: "subject,description,actualstart,activityid")
rest.AddHeader("OData-MaxVersion", value: "4.0")
rest.AddHeader("Accept", value: "application/json")
rest.AddHeader("OData-Version", value: "4.0")
rest.AddHeader("Authorization", value: "Bearer DYNAMICS_CRM_ACCESS_TOKEN")
let sbResponseBody = CkoStringBuilder()
success = rest.FullRequestNoBodySb("GET", uriPath: "/api/data/v9.0/phonecalls", sb: sbResponseBody)
if success != true {
print("\(rest.LastErrorText)")
return
}
var respStatusCode: Int = rest.ResponseStatusCode.intValue
if respStatusCode >= 400 {
print("Response Status Code = \(respStatusCode)")
print("Response Header:")
print("\(rest.ResponseHeader)")
print("Response Body:")
print("\(sbResponseBody.GetAsString())")
return
}
let jsonResponse = CkoJsonObject()
jsonResponse.LoadSb(sbResponseBody)
var i: Int
var count_i: Int
var odataContext: String? = jsonResponse.StringOf("\"@odata.context\"")
i = 0
count_i = jsonResponse.SizeOfArray("value").intValue
while i < count_i {
jsonResponse.I = i
var odataEtag: String? = jsonResponse.StringOf("value[i].\"@odata.etag\"")
var subject: String? = jsonResponse.StringOf("value[i].subject")
var description: String? = jsonResponse.StringOf("value[i].description")
var actualstart: String? = jsonResponse.StringOf("value[i].actualstart")
var activityid: String? = jsonResponse.StringOf("value[i].activityid")
i = i + 1
}
}
{
"@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"
}
]
}