Skip to main content

So I’ve been trying to POST an invoice to the lexoffice API (https://developers.lexoffice.io/docs/#files-endpoint-upload-a-file). I know Zapier supports a direct file upload to lexoffice, but I wanted to build my own requests to submit additional information together with the invoice.

The request includes the file and an additional key/value as form data to classify the file type (in my case “type”:”voucher”).

This is the cURL sample, that is mentioned in the API docs:

curl https://api.lexoffice.io/v1/files
-X POST
-H "Authorization: Bearer {accessToken}"
-H "Content-Type: multipart/form-data"
-H "Accept: application/json"
-F "file=@{PathToFile}" -F "type=voucher"

Posting that works fine.

I tried setting up a webhook POST in a Zap that does the same and looks like this:

The problem is, that the resulting post is rejected by the API. And while I was researching this, other people are having the same issue, sending multipart/form-data consisting of one or multiple files and additional form data in one request (even to other APIs, so not a lexoffice-specific issue).

The reason is: Zapier apparently is wrapping the additional form data in an data object.

To test this out I sent the (successful) curl request to webhook.site (a webhook testing webservice) and afterwards the same request built with Zapier.

This is the curl request (simplified):

CURL POST request

 

And this is what the request from Zapier looks like:

Zapier POST Request

As you can see, Zapier (compare the “Form values” section) is wrapping the provided key/value pairs from the “data”-section in another “data” element and I see absolutely no reason, why Zapier is doing that?

That way it’s not possible to replicate such CURL calls containing files AND additional data.

Hi @sbauer 

A possible workaround would be to use a Code step to make the API request: https://zapier.com/apps/code/help