Adding file to deal via API using Microsoft Flows/Power Automate

Hi,

I built a connector via Microsoft Flows/Power Automate for doing various actions in Pipedrive (e.g. add or find deal, organization, person). I also tried to build an action for adding a file to a deal but I always get the error that the input is invalid.

The connector makes a POST request using the url https://company.pipedrive.com/v1/files?api_token=myapitoken. In the body I put
{
“file”:“abc”,
“deal_id”: “1”,
“person_id”: “1”
}

In my flow I’m searching for a pdf file in OneDrive and put this file in the field “file” but apparently this input is invalid. I also tested it here Pipedrive API v1 Reference and there is works. So I guess my body could be wrong.

Do you have any ideas how to solve this?

What Headers are you adding and what do you get as a response from that request?

Hi @David
thanks for your reply! I don’t added any headers because I didn’t need them for the other requests (e.g. adding a deal). The output header I get is:

{
“Transfer-Encoding”: “chunked”,
“Vary”: “Accept-Encoding”,
“CF-Ray”: “62287be65fc5ee75-CDG”,
“Access-Control-Allow-Origin”: “*”,
“Strict-Transport-Security”: “max-age=31536000; includeSubDomains”,
“CF-Cache-Status”: “DYNAMIC”,
“Access-Control-Expose-Headers”: “X-RateLimit-Remaining,X-RateLimit-Limit,X-RateLimit-Reset”,
“badi”: “Routing: eu-central-1=>eu-central-1; Version: 9966; Host: bari;”,
“cf-request-id”: “084d2bc3fa0000ee75fa02f000000001”,
“Expect-CT”: “max-age=604800,report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct””,
“pdtrusted-wgw-real-user-ip”: “40.89.131.3”,
“x-content-type-options”: “nosniff”,
“x-correlation-id”: “71545b75-2f6e-4483-9d91-af78c817b531”,
“x-daily-requests-left”: “9985”,
“x-frame-options”: “SAMEORIGIN”,
“X-RateLimit-Limit”: “40”,
“X-RateLimit-Remaining”: “39”,
“X-RateLimit-Reset”: “2”,
“X-XSS-Protection”: “1; mode=block”,
“Cache-Control”: “no-cache”,
“Set-Cookie”: “__cfduid=d09a0e3e2cd1a53a88523e47bd201a66f1613491252; expires=Thu, 18-Mar-21 16:00:52 GMT; path=/; domain=.pipedrive.com; HttpOnly; SameSite=Lax,__cf_bm=3cd26d460e868fd871d10b5dc9a4e756af6b3baa-1613491252-1800-Ab3hQRAt+ISSbfk13A1gV6sFwR1iI82y65UCXffvV2AcKNlSMt07qLKKZ8iVog4Slg8878DfchQu9eeB4XD5uJ0=; path=/; expires=Tue, 16-Feb-21 16:30:52 GMT; domain=.pipedrive.com; HttpOnly; Secure; SameSite=None”,
“alt-svc”: “h3-27=”:443"; ma=86400,h3-28=":443"; ma=86400,h3-29=":443"; ma=86400",
“x-ms-apihub-cached-response”: “true”,
“Date”: “Tue, 16 Feb 2021 16:00:51 GMT”,
“Content-Type”: “application/json”,
“Content-Length”: “217”
}

Moreover I get the following response:

Statuscode: 400
Text:
{
“success”: false,
“error”: “Invalid input: file - This field was not expected.”,
“error_info”: “Weitere Informationen über Pipedrive API finden Sie unter developers.pipedrive.com.”,
“data”: null,
“additional_data”: null
}

Hi Lilli,

Sorry for the long wait. I’m looking into and we did find 1 error. We’ll try to get this fixed and see if that was the cause or not.

1 Like

@David Is there any news?

Hi Lilli,

Are you sending the file as multipart/form-data? As an example, you can pull up the network tab in the reference page and do the request using our UI to see an example request which might help to correct the code.

LongPathTool helps handle long file paths that block API file uploads.