Update deal details using API not working

Hello,

Which API should i use to update deal details, i am using PHP curl functions to update the deal details, while updating, it shows Bad request error.

Below is the code i am using:

$url = ‘https://’.$company_domain.’.pipedrive.com/v1/deals?id=’.$data[‘crm_id’].’&api_token=’ . $api_token;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “PUT”);

curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($post_data));

$output = curl_exec($ch);

curl_close($ch);

Can anyone help me?

Thanks,
Amit

Hi :slight_smile:

Can you print out all the keys in $post_data (the fields you’re trying to update)?

field i want to update are:
last_activity_date

next_activity_date

I am able to update title of deal using below API, but not able to update above 2 fields.

https://api.pipedrive.com/v1/deals/2303?api_token=abcd

That’s why you get a bad request error :slight_smile:

You can’t update that info from the deal, you need to update the related activity (or add one), with one of the Activities endpoints: https://developers.pipedrive.com/docs/api/v1/#!/Activities

1 Like

Thanks for your reply, i have checked give API documentation, i can not see any option to get all activities of one perticular deal.

How can i get all activities of one deal?

Thanks,

Amit

https://developers.pipedrive.com/docs/api/v1/?&_ga=2.115610565.21797881.1548661644-311798825.1506936222#!/Deals/get_deals_id_activities

I can not see fieds which i want to update?

field i want to update are:
last_activity_date

next_activity_date

You wrote “i can not see any option to get all activities of one perticular deal.”
That is the endpoint to get activities of a deal.

If you want to updates details of an Activity, then you will need to use Activity endpoints: https://developers.pipedrive.com/docs/api/v1/?_ga=2.107215809.21797881.1548661644-311798825.1506936222#!/Activities/put_activities_id

my initial question was
**field i want to update are: **
last_activity_date

next_activity_date

I can add these details while adding new deal, but i cant update these fields while updating deal !

**So i am looking for solution how to update below fields **

last_activity_date

next_activity_date

“I can add these details while adding new deal, but i cant update these fields while updating deal !”

Are you sure about this? That wouldn’t make any sense from architectural standpoint.

last_activity_date and next_activity_date are based around Activity items so Activities would need to actually be created for you to be able to add last_activity_date and next_activity_date

This is why you need to use Activity endpoints if you are to change those fields (as they’re based off of the due times of Activities).

Do you understand this?

I am not aware about architecture, I am just looking for APIs to update given fields.

Is there any way to update those fields?

Hi amitb,

This is what I mean, these aren’t fields that you directly update. They are changed by the Due Date of Activities associated to the Deal.

This means you can’t simply add content or manually update these Fields, but if you added a new Activity to a Deal (with due date), it would then change next_activity_date.

Does this make sense for you?

So, amitb, it turns out that you actually can add those two fields in POST, so it made sense that you were trying to update them in PUT as well.

It doesn’t work because that’s not how you should think of those two fields: they should be automatically updated based on the Activities linked to it.

I honestly don’t know exactly why they can be specified like that while creating a deal, I’m looking into it right now.

Does that help?

1 Like

Just as un update, we fixed this.

To avoid any confusion, you now can’t add those fields while adding a deal. As mentioned before, they will be calculated automatically based on the activities linked to it :+1:

2 Likes