[b]"How do I use curl to make a request from the command line?"[/b] or [b]"What's the best way to make a request w

24 Replies, 1265 Views

For a clean GET request, just:
```
curl https://example.com
```

Need JSON? Pipe it to `jq` for pretty formatting:
```
curl https://api.example.com/data | jq
```

Install `jq` if you don’t have it—it’s a game-changer!
If you’re dealing with APIs, `-H` is key. Here’s a real-world example:

```
curl -X GET -H "Authorization: Bearer YOUR_TOKEN" https://api.example.com/user
```

Also, `-v` helps debug when things go wrong.
Don’t overcomplicate it! Start with:

```
curl https://example.com
```

Then add flags as you need them.

For POST:
```
curl -X POST -d "name=John&age=30" https://example.com/submit
```

Check out [Postman](https://www.postman.com/) if you want a GUI alternative.



Users browsing this thread: 1 Guest(s)