Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

POST with curl without sending data

Tags:

curl

Is there a way to use curl to send a POST request without sending any data?

We usually post like:

curl --data @C:\mydata.txt http://1.2.3.4/myapi 

If you omit the --data you are doing a GET. How can you omit it and still do a POST?

like image 887
Marcus Leon Avatar asked May 21 '10 20:05

Marcus Leon


People also ask

Does curl default to POST?

By default you use curl without explicitly saying which request method to use. If you just pass in a HTTP URL like curl http://example.com it will use GET. If you use -d or -F curl will use POST, -I will cause a HEAD and -T will make it a PUT.

How do I use raw body data with curl?

curl's --data will by default send Content-Type: application/x-www-form-urlencoded in the request header. However, when using Postman's raw body mode, Postman sends Content-Type: text/plain in the request header. It should be noted though that the body part is sent exactly the same. This just changes a header.


1 Answers

Randomly found the solution on another post:

curl -X POST http://example.com

like image 178
Marcus Leon Avatar answered Sep 24 '22 10:09

Marcus Leon