在PHP中使用API​​在Dynamics CRM中创建事件 [英] Create incident in dynamics crm using api in php

查看:68
本文介绍了在PHP中使用API​​在Dynamics CRM中创建事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用php在Dynamics CRM中创建案例.为此,我可以看到标题,描述和客户是必需的.因此我尝试了以下代码:

Im trying to create case in dynamics CRM using php.For that I can see that title,description and customer is required.So that I tried below code:

  $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;'));

它显示代码":",消息":您应该指定父级联系人或帐户." 我试图使用导航属性.但是我找不到确切的property发送customerId.

It's showing "code":"","message":"You should specify a parent contact or account." Im trying to use navigation property.But I can't find the exact property to send customerId.

我尝试了以下链接: link1 link2 link3

I have tried with following links: link1link2link3

我尝试了很长时间,实在太沮丧了.

I'm trying for a long time.It's too frustrated.

尝试@Alex评论后,我引用了根据以下请求创建事件

After I tried @Alex comment,I referred create incidents with following request,

$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.此错误.

现在,我认为我们的请求是正确的,但格式不匹配.

Now I think our request is correct but format is mismatching.

推荐答案

最后一种情况是在php中使用以下请求创建的

Finally case is create using below request in php

$data = array("title"=>"test",
        "description" =>"case",
        "customerid_contact@odata.bind" =>"/contacts(c18df8d6-74d9-e511-80eb-c4346bac3990)"
        );

 $url ='https://yyyyy.crm.dynamics.com/api/data/v8.0/incidents';

这篇关于在PHP中使用API​​在Dynamics CRM中创建事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆