How to properly use curl POST JSON in my API requests? or What's the correct syntax for a curl POST J

14 Replies, 1876 Views

"Help! Can't figure out curl post json syntax for my API..."

Hey folks, struggling to get my curl post json request working. Tried a bunch of stuff but keep getting errors or empty responses.

Here's what I'm trying:
```bash
curl -X POST https://api.example.com/data -d '{"name": "test", "value": 123}'
```
But the server acts like it's not even JSON? Am I missing headers or something?

Also, seen people use `-H "Content-Type: application/json"`β€”is that *always* needed for curl post json?

Would love a *simple* example that actually works. Bonus points if you explain why my version fails.

Thanks in advance! (and pls no "RTFM" replies, I did... kinda πŸ˜…)

---
*PS: Using Windows cmd, if that matters. Quotes always mess me up.*

Messages In This Thread
How to properly use curl POST JSON in my API requests? or What's the correct syntax for a curl POST J - by - 26-07-2024, 04:20 AM



Users browsing this thread: 1 Guest(s)