I’m trying to attach a file url from Airtable to an invoice via a custom webhook in Zapier. This is what I have so far, but I’m having a hard time figuring out what to pass through in the “data fields”
We have an Enterprise account, just need help attaching the documents to the invoice via API.
hillel
October 26, 2020, 2:55pm
2
Hi,
Uploading documents isn’t supported though Zapier
I understand that it is not a direct connect, but there is a way to do it through a post request right?
hillel
October 26, 2020, 3:20pm
4
Yes, this is possible by sending a POST request with the API
Would you be able to show me the required parameters for doing this?
I have the url as follows:
https://ninja.dev/api/v1/documents?invoice_id=[ID]
headers as:
Content-Type:application/json
X-Ninja-Token: [TOKEN]
Problem is I don’t really know what to pass through besides that
hillel
October 26, 2020, 3:29pm
6
I believe the document needs to be sent in a parameter named ‘file’
Would you be able to send an example?
hillel
October 26, 2020, 3:38pm
8
Sorry, I don’t have one available
This did not work unfortunately
hillel
October 26, 2020, 3:38pm
10
Can you post your full cURL request
hillel
October 26, 2020, 3:41pm
13
I don’t see how the file is being sent? I suggest trying to get it working first using cURL and then attempt to transfer the settings to Zapier
sorry I uploaded the incorrect image to start
hillel
October 26, 2020, 3:42pm
15
I think the content type should be “multipart/form-data”
Getting an error of “forbidden”
If you can provide me an example curl request, I think I can translate it to the zapier format.
hillel
October 26, 2020, 3:45pm
17
Sorry, if I had one I’d share it
You aren’t able to provide me the parameters at all? I don’t need a live example I just need to know what data to pass through.
hillel
October 26, 2020, 3:49pm
19
The only parameter unique to the documents request is called ‘file’
hillel
October 26, 2020, 5:42pm
20
If you have a chance please try this format
curl -X POST https://domain.com/api/v1/documents?invoice_id=<your_id> \
-H 'Content-Type: multipart/form-data' \
-H 'X-Ninja-Token: TOKEN' \
-H 'X-Requested-With: XMLHttpRequest' \
-F _method=PUT \
-F 'file=@filename.png'
`
hillel
October 27, 2020, 6:49am
21
Correction…
curl -X POST https://domain.com/api/v1/documents?invoice_id=<your_id> \
-H 'Content-Type: multipart/form-data' \
-H 'X-Ninja-Token: TOKEN' \
-H 'X-Requested-With: XMLHttpRequest' \
-F 'file=@filename.png'