Attaching PDF Document Through The API

Yes, I did put the full path on my PC. Here is my most up to date curl request that returned this error.

curl -X POST URL/api/v1/documents 
  -H 'Content-Type: multipart/form-data' \
  -H 'X-Ninja-Token: TOKEN' \
  -H 'X-Requested-With: XMLHttpRequest' \
  -F 'file=@C:/Users/CWilliams/Documents/TemplateFiletest/TEST.txt'

I suggest trying with file in the same folder where you’re running curl

Also, it looks like the invoice_id parameter is missing from the URL

Moving the file to the same folder did not change anything. I am still getting the same error.

I was just testing with an without the invoice id parameter to see if it made any difference. It return the same error either way.

Sorry, I’m not sure. It’s working correctly for me.

Is there a way to debug this further to see why the file is not sending when I have it in my request? I am not sure where to go from here.

If you’re developer I can try to help you debug the code

I am a developer. I am just running the curl request in VS Code at this point. I just wanted to get a simple curl request working before integrating my application to use the documents API.

Could it be related to VS Code? Have you tried running the cURL from the command line?

Here’s the relevant code if you want to try to debug the request:

Good news! Visual Studio Code was the issue. The command line worked. I am seeing the document attached to the invoice. I am going to start implementing this into my app and let you know if I run into any further issues.

Thank you for your help.

1 Like