Reputation: 672
I build curl request with PUT request and with json request payload. I wanna see response headers and payload, I added -I arg, when sending request.My curl request :
curl -I -X PUT http://localhost:8080/v1/test -H 'X-RequestId:test' -H 'key:test' -H "Content-Type: application/json" -d "{\"status\":\"APPROVE\",\"rules\":null}"
But it showing me warning like this:
Warning: You can only select one HTTP request method! You asked for both POST
Warning: (-d, --data) and HEAD (-I, --head).
Upvotes: 0
Views: 2019
Reputation: 850
From the curl
man page:
-I, --head
(HTTP FTP FILE) Fetch the headers only! HTTP-servers feature the
command HEAD which this uses to get nothing but the header of a
document. When used on an FTP or FILE file, curl displays the
file size and last modification time only.
The -I
option automatically issues http request with HEAD
method, and this is what the error message is saying. By using -d, --data
with -I
the curl
doesn't know which http method to use, because first one uses POST
method implicitly and the second one uses HEAD
. Which is basically what the error message says: You can only select one HTTP request method!
What you probably want is lower case -i
option instead:
-i, --include
Include the HTTP response headers in the output. The HTTP re‐
sponse headers can include things like server name, cookies,
date of the document, HTTP version and more...
To view the request headers, consider the -v, --verbose option.
Or use -v
option to view both request and response headers.
Upvotes: 2