How to curl post a URL with proper syntax and headers? or What’s the correct way to curl post a URL?

14 Replies, 807 Views

400 usually means bad request, so your JSON might be malformed or missing something.

Quick tip: use `--data-raw` instead of `-d` if you’re having issues with special chars. Also, escape quotes if needed:

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

If that doesn’t work, maybe the endpoint requires URL-encoded data? Try `-d "key=value"` without JSON.

Messages In This Thread



Users browsing this thread: 1 Guest(s)