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

14 Replies, 770 Views

You might be missing quotes or escaping issues in your JSON. Try this:

```
curl -X POST https://example.com/api \
-H "Content-Type: application/json" \
-d @data.json
```

Put your JSON in a file (`data.json`) to avoid shell messing with the syntax.

Also, 400 could mean the server expects a different format. Check the API docs—some want form-data, not JSON.

Messages In This Thread



Users browsing this thread: 1 Guest(s)