How to get Person details in php array

Hi,

Please find attached copy for the issue I am facing, I want to set data for “person tab” in the deal, which contains “name”, “email”, “phone” I want to add these details via API

Please help me to create a proper array, so that I will pass it through curl’s in php.
f

I think you need to create the person first, using the endpoint:
https://developers.pipedrive.com/docs/api/v1/#!/Persons/post_persons
and then use the ID in that field when creating the deal.

I’m actually surprised you got a person with the name “Array”.

@Troels_Gorm_Rasmussen is correct. You first need to create the Person with the endpoint linked above, then pass the id as person_id when creating the deal :+1:

1 Like

Hello, can you help me?

$data_deal = array('person_id' => array('value' => 25533));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.pipedrive.com/v1/deals?api_token=xxxxxxx');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_deal);

Where this error?
Thanks in advance!

Hi Jean,

Could you perhaps explain yourself a bit more? What exactly are you trying to achieve and what error are you referring to?

1 Like

what I’m trying to do is assign a person to a deal using the ID of the person. very similar to the other person’s question from this same thread
Thanks David.

Thanks for explaining more, but you mention an error in your original post. Could you tell me what error you’re encountering?

No, just dont work. No change nothing in pipedrive.

hi dani , can you help me?

hi @cyberpolito
person_id should be an integer, not an array.

Please, try changing

$data_deal = array('person_id' => array('value' => 25533));

to

$data_deal = array('person_id' => 25533);
1 Like

Thanks dani, but i cant do work!. do you have what is the problem?

$url = 'https://api.pipedrive.com/v1/deals/'.$IDPipe.'?api_token=xxxxxxx';

$data_deal = array('person_id' => 25533);

$ch = curl_init();  
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_deal);
$output = curl_exec($ch);
curl_close($ch);  

If you’re updating an existing deal you probably need to set

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");

Do you get any specific error?

With
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
the error is : “Content-Type: not supported”

Why don’t you use one of the PHP library available to handle all these things for you?

There’s an official library, and a community library. Pick one and it will save you a lot of time down the road :slight_smile:

which one do you recommend

The official one :slight_smile: