Need a simple curl POST example – can anyone share a quick snippet? or Struggling with a curl POST example – any

24 Replies, 1715 Views

Hey! Here’s a dead-simple curl POST example for your case:

```
curl -X POST https://example.com/api \
-H 'Content-Type: application/json' \
-d '{"name": "test"}'
```

The `-X POST` is optional (curl defaults to POST with `-d`), but I like being explicit.

And yes, you *usually* need the `Content-Type` header—some APIs will ignore your data without it.

If you’re still stuck, try `-v` to see the full request/response. Helps debug those 400 errors!

Messages In This Thread



Users browsing this thread: 1 Guest(s)