How do I properly send a POST request in cURL? or What's the correct way to make a POST request in cU

18 Replies, 1262 Views

Dude, same issue here a while back. For a post request in curl, the `-d` flag is correct, but the server might reject it without headers. Try this:

```
curl -X POST https://example.com/api \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "param1=value1¶m2=value2"
```

Also, if it’s a REST API, they often want JSON. Swap the header to `application/json` and format the data like `-d '{"key":"value"}'`.

Messages In This Thread



Users browsing this thread: 1 Guest(s)