Hello,
I try to integrate PBX and Vtiger 7.1.0 using Restful API, but I having error message when posting the Event call report into CRM
The log as below :
2019/05/18 08:47:59.596|8978|0028|Verb|Performing POST request to 'https://vtiger.yourdomain.com/webservice.php?' with following form values:
2019/05/18 08:47:59.596|8978|0028|Verb| 'operation' = 'create'
2019/05/18 08:47:59.596|
A
Community Solution
✓ Answered
I have this error too please guide me...
I use the code below to add comment to a Module in Vtiger CRM: problem is that when I want to add comment for Leads it works correctly; but when I set "related to" for my custom module show error below:
Invalid reference specified for related_to... REFERENCE_INVALID
Please help me to solve it.
check my code and put your key and url to test it please
<?php
function callvtiger($url, $params, $type = "GET")
{
$is_post = 0;
if ($type == "POST") {
$is_post = 1;
$post_data = $params;
} else {
$url = $url . "?" . http_build_query($params);
}
$ch = curl_init($url);
if (!$ch) {
die("Cannot allocate a new PHP-CURL handle");
}
if ($is_post) {
curl_setopt($ch, CURLOPT_POST, $is_post);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
$return = null;
if (curl_error($ch)) {
$return = false;
} else {
$return = json_decode($data, true);
}
curl_close($ch);
return $return;
}
$userName = "admin";
$userAccessKey = "";
$Url = 'https:///webservice.php';
$sessionData = callvtiger($Url, array(
"operation" => "getchallenge",
"username" => $userName
));
echo "<pre>";print_r($sessionData);echo "</pre>"; echo "<br><br><br><br>";
$challengeToken = $sessionData['result']['token'];
$generatedKey = md5($challengeToken . $userAccessKey);
$args = array(
"operation" => "login",
"username" => $userName,
"accessKey" => $generatedKey
);
$dataDetails = callvtiger($Url, $args , "POST");
echo "<pre>";print_r($dataDetails);echo "</pre>"; echo "<br><br><br><br>";
$sessionid = $dataDetails['result']['sessionName'];
$userId = $dataDetails['result']['userId'];
$id = explode("x",$userId );
$args = array(
"operation"=>"create",
"format"=>"json",
"sessionName"=>$sessionid,
"elementType"=>"ModComments",
"element"=> json_encode( array(
"commentcontent"=>"this is a test",
"assigned_user_id"=>$userId,
"related_to"=>"46x246",
) )
);
echo "<pre>";print_r($args);echo "</pre>"; echo "<br><br><br><br>";
$getCreateDetail = callvtiger($Url, $args, "POST");
echo "<pre>";print_r($getCreateDetail);echo "</pre>"; echo "<br><br><br><br>";
?>