Reputation: 311
Hi I am using cURL to upload pdf file to remote server with POST method.
I tried several variants, and got several different messages(errors), two most significant:
curl -X POST https://waapi.pepipost.com/api/v2/media/upload/ -H 'Authorization: Bearer myAuthorizationToken' -H 'Content-Type: document' "@C:\Users\Slomil\Desktop\UserGuide.pdf"
with the error curl: (3) Port number ended with '\'
.
Also, I've tried to change address to '/' so new curl command looks like
curl -X POST https://waapi.pepipost.com/api/v2/media/upload/ -H 'Authorization: Bearer myAuthorizationToken' -H 'Content-Type: document' "@C:/Users/Slomil/Desktop/UserGuide.pdf"
and received error curl: (1) Protocol "@C" not supported or disabled in libcurl
.
I also search for previous answers about that on stackoverflow, and tried to use that help as my new cURL command, and it was also unsuccessful.
Does someone perhaps know what can be the issue here? I thought that my address to the file is wrong.. but don't know how else should it be written in the command..Here I've changed only the addresses from "\"
to "/"
, thinking that the address is the problem, maybe in those slashes.. Thank you very much!:)
Upvotes: 5
Views: 7175
Reputation: 58014
There's more than one way to "upload a file to a URL", so we cannot actually know unless you give us more details.
But what's clear is that that you lack either a -d or a -F option on your command line, and you should drop the -X POST
.
If you upload with a multipart, which is how most "uploads" to HTTP works, it could be something like this:
curl https://waapi.pepipost.com/api/v2/media/upload/ -H 'Authorization: Bearer myAuthorizationToken' -F "file=@C:\Users\Slomil\Desktop\UserGuide.pdf"
Note that this command line sets the upload part to get the name file, which you should change to the name you want.
If you just want to send the binary file "raw" in a POST (which your setting of Content-Type might indicate you want), use --data-binary like this:
curl https://waapi.pepipost.com/api/v2/media/upload/ -H 'Authorization: Bearer myAuthorizationToken' -H 'Content-Type: document' --data-binary "@C:\Users\Slomil\Desktop\UserGuide.pdf"
(I copied the Content-Type from the question, although it looks unusual and odd.)
Upvotes: 6