我想使用 API v2 在 zoho crm 中插入数据。首先创建一个数组,然后我编码 json .Request url https://www.zohoapis.com/crm/v2/Contacts 。 但我收到了这个错误。
代码:
$authtoken = ***********;
$fields={"data":["{\"Last_Name\":\"Test John insert\",\"Email\":\"<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5226372126383a3d3c12383a3d3c7c313d3f" rel="noreferrer noopener nofollow">[email protected]</a>\"}"]};
$zoho_url = "https://www.zohoapis.com/crm/v2/Contacts";
错误:
{"data":[{"code":"INVALID_DATA","details":{"expected_data_type":"jsonobject","index":0},"message":"invalid data","status":"error"}]}
最佳答案
工作示例:
$fields = json_encode(
array(
"data" => array([
"Company" => "abc",
"Last_Name" => "Tom",
"City" => "Egham"
],
[
"Company" => "abc",
"Last_Name" => "Jerry",
"City" => "Egham"
])
)
);
以这种方式发送 header :
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($fields),
sprintf('Authorization: Zoho-oauthtoken %s', $oauth)
);
关于php - 在 PHP 中的 zoho api v2 中插入记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50980779/