Reputation: 592
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
Upvotes: 47
Views: 99185
Reputation: 5011
Adding a header like this should do the trick:
-H 'content-length: 1000'
Full example:
$ curl -v -XPOST -H 'content-length: 1000' https://example.com
# ... snip ...
> POST / HTTP/2
> Host: example.com
> User-Agent: curl/8.5.0
> Accept: */*
> content-length: 1000
>
# ... snip ...
Upvotes: 13
Reputation: 6125
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
Upvotes: 49
Reputation: 165
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.
Upvotes: 10