Update lead error 'Not found'

Hi!

I’m trying to link a lead to a person. But I receive a 404 response and a “Not Found” content.

I’m using the PATCH method with python:


import json
import requests
headers = {‘Content-type’: ‘application/json’}
body= {“person_id”: 3773}
url= f"https://{company_name}.pipedrive.com/api/v1/leads/?id=532c0b40-3913-11ec-90e4-e5e59deb1413&api_token={api_token}"
r = requests.patch(url, data=json.dumps(data), headers=headers)
print(r.content, r.status_code)

b'Not Found' 404

I can GET the lead by it’s UUID ID, and I can GET the person by it’s ID. I don’t understand why I can’t update the lead.

Additional information, the lead is linked to an organizationl. Could be this the problem?

Can you help me with that?

Hey @DavidLopez
Is it related to the previous issue?

Hi @Hem!

I did the change you propose. This time, I get a 200 status code response. But the response content shows me that not change is done to the lead. The lead is still linked to the previous person_id, not the one that I pass in the payload, additionaly. I can check that the change is not made going to the lead details in the website.This is my snipet and response:

url= f"https://{company_name}.pipedrive.com/api/v1/leads/532c0b40-3913-11ec-90e4-e5e59deb1413?api_token={api_token}"

body= {
        "person_id": {some_id_person_integer,  eg :1510}
    }

r = requests.patch(url, data=json.dumps(body))

print(r.status_code, r.content)

200 b'{"success":true,"data":{"id":"532c0b40-3913-11ec-90e4-e5e59deb1413","title":"fincaraiz: 5508870","owner_id":12170254,"creator_id":12170254,"label_ids":["35087150-90dd-11eb-a24b-df0a24747ce6"],"value":null,"expected_close_date":null,"person_id":90,"organization_id":17,"is_archived":false, ....

I am missing something?

Hi @Hem!

I solved the issue by adding the 'content-type': 'application/json' header:

import json
import requests

url= f"https://{company_name}.pipedrive.com/api/v1/leads/532c0b40-3913-11ec-90e4-e5e59deb1413?api_token={api_token}"

headers = {'content-type': 'application/json'}

body= {
        "person_id": 4210
    }

r = requests.patch(url, data=json.dumps(body), headers=headers)

Thanks for your help

1 Like