0

I'm trying to update a deal in pipedrive CRM using the API. What I'm trying to do is to update the owner of a deal to a new user. But this is not successful.

docs

Here is my code:

$deal_id = 31811; //the id of the add that i want to update

$deal = array(
    "user_id" => 1858654, //the id of the user that will be the new owner
    "stage_id" => 1 //the stage id where the deal should be
);

$api_token = "x";
$url = "https://api.pipedrive.com/v1/deals/".$deal_id."?api_token=" . $api_token;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $deal);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

Here is the returned error.

array (
  'url' => 'https://api.pipedrive.com/v1/deals/31811?api_token=X',
  'content_type' => NULL,
  'http_code' => 0,
  'header_size' => 0,
  'request_size' => 0,
  'filetime' => -1,
  'ssl_verify_result' => 1,
  'redirect_count' => 0,
  'total_time' => 0.32900000000000001,
  'namelookup_time' => 0,
  'connect_time' => 0.157,
  'pretransfer_time' => 0,
  'size_upload' => 0,
  'size_download' => 0,
  'speed_download' => 0,
  'speed_upload' => 0,
  'download_content_length' => -1,
  'upload_content_length' => -1,
  'starttransfer_time' => 0,
  'redirect_time' => 0,
  'redirect_url' => '',
  'primary_ip' => 'x.x.x.x',
  'certinfo' => 
  array (
  ),
  'primary_port' => x,
  'local_ip' => 'x.x.x.x',
  'local_port' => x,
)error occured during curl exec. Additioanl info: 
Edvard Åkerberg
  • 2,181
  • 1
  • 26
  • 47
  • Do you get any error? – Tom Nov 02 '16 at 09:43
  • There is no 'stage_id' parameter in docs. – Gowri Nov 02 '16 at 09:50
  • @Gowri on PUT Update a deal/deals/:id there is a field called stage_id – Edvard Åkerberg Nov 02 '16 at 09:56
  • @Tom this do not return any error. – Edvard Åkerberg Nov 02 '16 at 09:56
  • Can you try `print_r($output)`. What response comes from api. – Gowri Nov 02 '16 at 10:00
  • @Gowri i do not get any result at all. It returns false – Edvard Åkerberg Nov 02 '16 at 10:12
  • Have you tried the endpoint calling using "Tryit" option in developers site. Using your api access key. – Gowri Nov 02 '16 at 10:21
  • I'm having the same issues, I think it may be a bug in the API. I can add deals, but not edit them. I'll ask PipeDrive. – AndyGaskell Nov 14 '16 at 09:47
  • 1
    @AndyGaskell If I remember correctly this error occured because cURL was not activated on my WAMP server. Here is a link to my thread that solved the problem. http://stackoverflow.com/questions/40401608/php-7-0-curl-not-working-wamp-on-windows-10-64-bit – Edvard Åkerberg Nov 14 '16 at 10:51
  • @EdvardÅkerberg thanks for the reply, I think that's not the solution in my case unfortunately. I'm using php7, but on Linux, also, many other API calls work ok, it seems I just can't edit deals. Using your code above, just change the api key, deal id and user id, I get "{"status":false,"error":"Unknown method ."}". Did the above code work for you once you activated cURL? – AndyGaskell Nov 14 '16 at 11:35
  • 2
    I found the problem in my code, which is also in the above example. Using POST doesn't work, it has to be PUT. My fault, as it does say in the API docs. – AndyGaskell Nov 14 '16 at 12:00

0 Answers0