How Do I Send a CURL POST Request with Headers and JSON Data? or What’s the Correct Syntax for a CURL

18 Replies, 926 Views

Yo, had the same issue last week! Turns out my CURL POST request was failing cuz the server expected `Content-Length` header. Added `-H "Content-Length: $(wc -c < data.json)"` and it worked.

Also, `jq` is your friend for validating JSON before sending:
```bash
echo '{"key": "value"}' | jq empty
```
No output? Good JSON.

Messages In This Thread



Users browsing this thread: 1 Guest(s)