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

24 Replies, 1622 Views

Try this curl POST example—it’s what I use daily:

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

If it fails, copy-paste your exact command + error here. Might be a server-side thing.
For debugging, add `-v` to see the raw HTTP exchange. Here’s the command:

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

Sometimes the error details are hidden in the verbose output.
If you’re on Windows, PowerShell’s `curl` is an alias for `Invoke-WebRequest`. Use `curl.exe` instead for the real deal.

Here’s the command:

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

Note the escaped quotes—Windows hates JSON sometimes.



Users browsing this thread: 1 Guest(s)