Associate CRM objects contact to deal (I have a error)

New Contributor

Hey Guys, 

I have a small problem, can you help me please. I am running this php script and it gives me an error.  I want to associate a contact with a deal. 

 

  • fromObjectId is a contact exist in Hubspot
  • toObjectId is a deal exist in Hubspot

I do not understand why this error gives me, with what I am wrong?! I entered in the variable $ hapikey the correct key.

 

{"fromObjectId":18801,"toObjectId":1565549700"category":"HUBSPOT_DEFINED","definitionId":4}string(188) "{"status":"error","message":"Invalid input JSON: No content (empty input stream)

 

 

<?php
$hapikey = "api is ok";
$array_put= array("fromObjectId"=> 18801, "toObjectId"=>1565549700 , "category"=> "HUBSPOT_DEFINED", "definitionId"=>4);

    $put_json = json_encode($array_put);


$endpoint_deal="https://api.hubapi.com/crm-associations/v1/associations?hapikey=".$hapikey;
$cher = @curl_init();
@curl_setopt($cher, CURLOPT_PUT, true);
@curl_setopt($cher, CURLOPT_URL, $endpoint_deal);
@curl_setopt($cher, CURLOPT_PUTFIELDS, $put_json);
@curl_setopt($cher, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
@curl_setopt($cher, CURLOPT_RETURNTRANSFER, true);
$responser = @curl_exec($cher);
@curl_close($cher);
echo $put_json;
var_dump($responser);

?>

 

Thanks.

 

Reply
0 Upvotes
1 Reply 1
Highlighted
Community Manager

Hey @Andrew_nicholas,

 

It looks like this is a similar issue posted here and I have responded to that forum thread.

 

Let me know if there's any further question on this!