7

在 Joomla 应用程序中,我得到如下用户信息,然后我需要通过他们的 REST API 将用户信息保存为 Dynamics 365 数据库中的联系人。

                    $user = JFactory::getUser();
                    $username = $user->username;
                    $name = $user->name;

我已经查找了有关 Web API 和 REST API 的 Dynamics 文档,例如thisthis,但它们都没有提供有用的信息,我如何调用 API 来添加新联系人。目前,我正在通过以下 URL 连接到 Dynamics 365 Web 应用程序:http ://example.com:8088/mysite/api/data/v8.2 。链接的帖子还讨论了 REST API,但只是查询。我正在寻找一种使用 REST API 将数据发布到 Dynamics CRM 的方法。

4

1 回答 1

6

使用 crm webapi 创建联系人的有效负载将如下所示:阅读更多

POST [Organization URI]/api/data/v8.2/contacts HTTP/1.1
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json

{
    "firstname": "Arun",
    "lastname": "Vinoth"
}

抱歉,我不是 PHP 背景,但此链接可能会对您有所帮助。

更新
我浏览了一下。从SO 答案中找到以下代码示例。使用 CRM URL更新[Organization URI],例如。https://testorg.crm.dynamics.com

$url = '[Organization URI]/api/data/v8.2/contacts';
$data = array('firstname' => 'Arun', 'lastname' => 'Vinoth');

// use key 'http' even if you send the request to https://...
$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
        'method'  => 'POST',
        'content' => http_build_query($data),
    ),
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

var_dump($result);
于 2018-07-28T23:56:49.033 回答