How do I properly use curl http post for sending data? or What's the correct syntax for a curl http p

16 Replies, 1748 Views

Hey! For a basic curl http post with JSON data, you should use `-H "Content-Type: application/json"` and `--data` (or `-d`). Your command is close, but the `-X POST` is redundant since `-d` implies POST. Try:

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

If it’s still not working, check if the API expects auth headers or other params. For debugging, add `-v` to see the full request/response.

Messages In This Thread



Users browsing this thread: 1 Guest(s)