Creates a phone call record regarding the Fourth Coffee account (b6a19cdd-88df-e311-b8e5-6c3be5a8b200), regarding the "Faulty product catalog" incident (c49e62a8-90df-e311-9565-a45d36fc5fe8), from the system user Allie Bellew (832698d1-b86a-47b5-a9a3-0cc710eb22e4), to the contact Gabriele Cannata (57a0e5b9-88df-e311-b8e5-6c3be5a8b200). A successful response is indicated by a 204 response status code with no response body.
curl -X POST https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/phonecalls \
-H "Accept: application/json" \
-H "Content-Type: application/json; charset=utf-8" \
-H "OData-MaxVersion: 4.0" \
-H "OData-Version: 4.0" \
-H "Authorization: Bearer DYNAMICS_CRM_ACCESS_TOKEN" \
-d '{
"subject": "Sample Phone Call 123",
"phonenumber": "3125551920",
"description": "Sample phone call created using the Chilkat Rest API",
"scheduledend": "2018-04-29T11:56:21Z",
"regardingobjectid_account@odata.bind": "/accounts(b6a19cdd-88df-e311-b8e5-6c3be5a8b200)",
"actualdurationminutes": 25,
"directioncode": true,
"phonecall_activity_parties": [
{ "partyid_systemuser@odata.bind": "/systemusers(832698d1-b86a-47b5-a9a3-0cc710eb22e4)",
"participationtypemask": 1 },
{ "partyid_contact@odata.bind": "/contacts(57a0e5b9-88df-e311-b8e5-6c3be5a8b200)",
"participationtypemask": 2 },
{ "partyid_incident@odata.bind": "/incidents(c49e62a8-90df-e311-9565-a45d36fc5fe8)",
"participationtypemask": 8 }
]
}'
#include <C_CkRest.h>
#include <C_CkJsonObject.h>
#include <C_CkStringBuilder.h>
void ChilkatSample(void)
{
HCkRest rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkJsonObject json;
HCkStringBuilder sbRequestBody;
HCkStringBuilder sbResponseBody;
int respStatusCode;
rest = CkRest_Create();
// URL: https://my-dynamics-domain.api.crm.dynamics.com/api/data/v9.0/phonecalls
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
success = CkRest_Connect(rest,"my-dynamics-domain.api.crm.dynamics.com",port,bTls,bAutoReconnect);
if (success != TRUE) {
printf("ConnectFailReason: %d\n",CkRest_getConnectFailReason(rest));
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
return;
}
json = CkJsonObject_Create();
CkJsonObject_UpdateString(json,"subject","Sample Phone Call 123");
CkJsonObject_UpdateString(json,"phonenumber","3125551920");
CkJsonObject_UpdateString(json,"description","Sample phone call created using the Chilkat Rest API");
CkJsonObject_UpdateString(json,"scheduledend","2018-04-29T11:56:21Z");
CkJsonObject_UpdateString(json,"\"regardingobjectid_account@odata.bind\"","/accounts(b6a19cdd-88df-e311-b8e5-6c3be5a8b200)");
CkJsonObject_UpdateNumber(json,"actualdurationminutes","25");
CkJsonObject_UpdateBool(json,"directioncode",TRUE);
CkJsonObject_UpdateString(json,"phonecall_activity_parties[0].\"partyid_systemuser@odata.bind\"","/systemusers(832698d1-b86a-47b5-a9a3-0cc710eb22e4)");
CkJsonObject_UpdateNumber(json,"phonecall_activity_parties[0].participationtypemask","1");
CkJsonObject_UpdateString(json,"phonecall_activity_parties[1].\"partyid_contact@odata.bind\"","/contacts(57a0e5b9-88df-e311-b8e5-6c3be5a8b200)");
CkJsonObject_UpdateNumber(json,"phonecall_activity_parties[1].participationtypemask","2");
CkJsonObject_UpdateString(json,"phonecall_activity_parties[2].\"partyid_incident@odata.bind\"","/incidents(c49e62a8-90df-e311-9565-a45d36fc5fe8)");
CkJsonObject_UpdateNumber(json,"phonecall_activity_parties[2].participationtypemask","8");
CkRest_AddHeader(rest,"Content-Type","application/json; charset=utf-8");
CkRest_AddHeader(rest,"OData-Version","4.0");
CkRest_AddHeader(rest,"Accept","application/json");
CkRest_AddHeader(rest,"OData-MaxVersion","4.0");
CkRest_AddHeader(rest,"Authorization","Bearer DYNAMICS_CRM_ACCESS_TOKEN");
sbRequestBody = CkStringBuilder_Create();
CkJsonObject_EmitSb(json,sbRequestBody);
sbResponseBody = CkStringBuilder_Create();
success = CkRest_FullRequestSb(rest,"POST","/api/data/v9.0/phonecalls",sbRequestBody,sbResponseBody);
if (success != TRUE) {
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRest_getResponseStatusCode(rest);
if (respStatusCode >= 400) {
printf("Response Status Code = %d\n",respStatusCode);
printf("Response Header:\n");
printf("%s\n",CkRest_responseHeader(rest));
printf("Response Body:\n");
printf("%s\n",CkStringBuilder_getAsString(sbResponseBody));
CkRest_Dispose(rest);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
CkRest_Dispose(rest);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
}