How to properly send a curl post request with JSON data? or Why is my curl post request returning a 4

14 Replies, 1562 Views

Hey! A 400 error usually means the server didn’t like your request. For a curl post request, you *definitely* need the `Content-Type: application/json` header. Try this:

```bash
curl -X POST -H "Content-Type: application/json" -d '{"key": "value"}' https://api.example.com/data
```

Also, use `-v` to see verbose output—it’ll show you the full request/response. If it’s still failing, maybe the endpoint requires auth? Check the API docs!

Messages In This Thread



Users browsing this thread: 1 Guest(s)