How can I pass content-length eg. --header Content-Length:1000
in curl command. I used it like this in command but it did't work
curl -v -X POST -u "[email protected]:xxx123" \ --header "Content-Length: 1000" \ --header "Content-Type: multipart/mixed" \ --header "X-REQUEST-ID:7fc7d038-4306-4fc5-89c3-7ac8a12a30d0" \ -F "request={\"bumId\":\"d51f2978-5ce8-4c71-8503-b0ca438741dd\",\"fileType\":\"imageFile\"};type=application/json" \ -F "file=@D:/file.pdf" \ "http://localhost:9090/pro/v1/files"
This command posts file to a web services developed in Jersey Java
To pass multiple headers in a curl request you simply add additional -H or --header to your curl command. For standard HTTP header fields such as User-Agent, Cookie, Host, there is actually another way to setting them.
By default curl sets appropriate Content-Length header for you when data is provided with -d parameter. In your case the server seems to wait for some data in the body. But for some reason you decided to pass the data in the url.
The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET.
You can use -d ""
causes CURL to send a Content-Length: 0
,
see Header 'Content-Length: 0' is missing when I do curl -X POST $URI
Try this: curl -X POST http://localhost:9090/pro/v1/files -d "Content-Length: 0"
curl
's -d
flag allows you to add data to the body of the request. According to its docs:
-d, --data (HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With