【发布时间】:2017-02-28 05:58:15
【问题描述】:
我正在尝试使用 php 在动态 CRM 中创建案例。为此我可以看到标题、描述和客户是必需的。所以我尝试了以下代码:
$authHeader = 'Authorization:' . $type.' '.$access_token;
//Request for incidents
$data = array("title"=>"api_incident_title",
"description" =>"api_incident_description",
"primaryContactid" =>"https://vonageholdings.crm.dynamics.com/api/data/v8.0/accounts(ebaf25a6-f131-e611-80f8-c4346bac3990)"
);
//URL
$url ='https://vonageholdings.crm.dynamics.com/api/data/v8.0/incidents';
//request for incidents
$data_string = json_encode($data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array($authHeader,
'Content-Type:application/json','Accept:application/json;'));
它显示 "code":"","message":"你应该指定一个父联系人或帐户。" 我正在尝试使用导航属性。但我找不到确切的 @ 987654326@发送customerId。
试了半天,太郁闷了。
在我尝试@Alex 评论后,我通过以下请求推荐了create incidents,
$data = array('primarycontactid@odata.bind' =>"https://xxxx.crm.dynamics.com/api/data/v8.0/contacts(4bafdfb0-08d7-e511-80eb-c4346bac3990)",
'incident_customer_accounts'=>array("title"=>"case_account","description" =>"case")
);
它显示A node of type 'StartObject' was read from the JSON reader when trying to read the contents of the navigation property 'incident_customer_accounts'; however, a 'StartArray' node was expected.这个错误。
现在我认为我们的请求是正确的,但格式不匹配。
【问题讨论】:
-
您的最后一个错误(“A 类型的节点...”)看起来像是数据结构与 JSONReader 期望的问题,我将其转移到自己的问题上它
-
是的@Alex。为此需要帮助。使用什么结构来发布数据?
标签: php api dynamics-crm-2011 microsoft-dynamics navigation-properties