Leads API: "title" fails because "title" is required

I’m trying create a new Lead through an API call. This works successfully via the Pipedrive API Reference webpage, but fails when I try this via Postman or other tools.

Headers:
{ "Accept": "application/json", "Content-Type": "application/json" }

I’m submitting via token, so something like:
https://api.pipedrive.com/v1/leads?api_token=randomletters

The body of my json is simply:
{ "title": "Test", "owner_id": 11566939, "person_id": 2436 }

I receive the following response:
{ "success": false, "data": null, "additional_data": null, "error": "provided dataset is not valid", "error_info": "child \"title\" fails because [\"title\" is required]" }

I’ve tried this a multitude of ways, but I cannot get this to work. What’s strange is that this works via the webpage ( Pipedrive API v1 Reference) using the same exact information, but it fails for me on multiple toolsets.

Can someone else point me in the right direction here? I’m successfully using other API endpoints like organizations, contacts and deals in the same manner as above without issues.

Thanks for any help.

1 Like

I’ve spent some time looking at my other API calls for person or org and I think there’s something different and/or incorrect with the /leads endpoint. When using person and missing the name field, I receive a proper error message in the error field about missing information.

With /leads, this error is different

{ "success": false, "data": null, "additional_data": null, "error": "provided dataset is not valid", "error_info": "child \"title\" fails because [\"title\" is required]" }

Can someone from Pipedrive take a look at this endpoint? Although it’s weird that I’m the only one having this issue. :sweat:

Can anyone help with this, as I’m completely blocked here.

Hey Eric,

Sorry for the wait, I started investigating yesterday on this, but couldn’t replicate it.

After speaking to our team behind the Leads endpoints, one developer suggesting using the following curl:

curl --location --request POST 'https://api.pipedrive.com/v1/leads?api_token=xxx' \
--header 'Content-Type: application/json' \
--header 'accept: *' \
--data-raw '{
    "title": "title",
    "person_id": 1
}'

Hi David,
Thank you so much for the reply. It wasn’t working for me at first in Postman, then I messed with the headers in Postman and then it started posting correctly. I believe I had Accept: application/json as a header and that was what was failing. Or something else changed.

Anyway, with
Content-Type: application/json
Accept: */*

as headers, it does seem to work for me now. Thanks again.

David,
I did a bit more testing and I think the key component is the inclusion of the Content-Length header. If that header is missing, I get the same “title” is required error. If that header is included, then I receive a successful result. As far as I can tell, this header isn’t required on other Pipedrive endpoints. However this header is not shown your curl example.

1 Like

Thanks for looking into this more and letting me know what you uncovered.

I will look into this further and see why the /leads endpoint is different in this way :+1:

hello guys,

I’ve found this thread while looking for a solution to a problem I am having with zapier and pipedrive. (zapier only supports DEALS but not LEADS yet by default in the options, so I am trying to set something with webhooks).

I was told (by zapier) to look into the pipedrive API, so I went and took the url request and added that to create a lead, but seems like it does not recognize data… do you have any idea why this could happen please? also is there any plan to get “create lead” as a default in zapier? we can only do deals atm. Let me know if you have any insights please.
Thanks

-Manuel

I noticed there is this headers field, maybe this is the issue? although I am not sure what should I put here. (sorry if this is a basic question I am not a developer and fairly new to pipedrive).

Thanks for any feedback!

Hi @Interactivo_Pro,

Adding Leads as an option is entirely up to Zapier unfortunately, but I believe they’re working to add them in the not too distant future.

As for trying to add Leads through Webhook (via Zapier), I haven’t tried this before, but let me do some testing and see if I can come up with something.

hi @David, sorry for the delay, thanks for the reply! we are evaluating to do this integration natively from webflow to pipedrive if possible to avoid issues. Will post back once we start this, thank you!

cheers

-manuel

1 Like

@Interactivo_Pro, @David. Maybe this will help. Here’s my zapier setup that’s successfully creating leads in pipedrive. There’s a step before this that creates the Contact in pipedrive, then I assign the Lead to the Contact. I had to use a Custom Request and format the JSON and set the headers. This was the only way I could get this to be successful, all other methods returned an error that’s in the title of this thread. Hope this helps.

1 Like

I had this same issue today. No issues adding persons or organizations, but leads was giving me the title error described by Eric. I tried making a request with no parameters and got the same message back. This leads me to believe POSTing the /leads endpoint is more finnicky than /persons or /organizations for some reason. Changing my request headers ended up solving the issue.

In my request headers I originally had -
Content-Type: application/json; utf-8
Accept: application/json

I changed these to -
Content-Type: application/json
Accept: *

1 Like

Hi @PaulB

I’m having the same issue but cannot workout how to change the headers. Could you please help?

$data = array(
'title' => 'Test New Lead',
'note' => 'Quick note test',
'person_id' => '190',
);

$headers = array(
    'Accept:' => '*.*', // here I did try with * only with & without content-length 
    'Content-Type:'=> 'application/json',
    'Content-length:' =>  '0',
);

//POST request
$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL =>              $url,
    CURLOPT_RETURNTRANSFER =>   true,
    CURLOPT_ENCODING =>         "",
    CURLOPT_MAXREDIRS =>        10,
    CURLOPT_TIMEOUT =>          30,
    CURLOPT_HTTP_VERSION =>     CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST =>    "POST",
    CURLOPT_POSTFIELDS =>       $data,
    CURLOPT_HTTPHEADER=>        $headers,
]);

Hey @honoslc , my PHP is rusty at best and I’m on a phone, so apologies for poor formatting. I did this in Java with a URLConnection. Are you sure your syntax for the http headers is correct? It looks like you’re making a map with keys for the header names and values being the header value, but the examples I saw with some quick googling were just arrays of strings in the format ‘Name: Value’ (this unrelated SO post is one: https://stackoverflow.com/a/15134580)

If that’s not it, maybe try asterisk slash asterisk (can’t format that correctly) for Accept instead of * without the content-length?

Thanks @PaulB. Yes I tried different approaches when building the array, none works. Same for asterics I’ve tested with 1 or two of them, with and without . in the middle.
Code is identical to the add persons and organisations (both working) the only difference is the endpoint /leads in the $url
I’ll have a look again in the morning to see if I’m missing something.
BR

Resolved … missing space in CURLOPT_HTTPHEADER=> now that I’ve added the space it works fine e.g. CURLOPT_HTTPHEADER => [ "Content-Type: application/json" ],

I’ve also encoded the array of data json_encode($data) because with CURLOPT_VERBOSE => true, I’ve noticed the /leads endpoint appears to be sending Content-Type: multipart/form-data; by default, /persons and /organisations don’t require any encoding or headers and use Content-Type: application/json by default.