cURL cheatsheet

Shortcuts

Basics GET, POST, PUT, and DELETE

Get example,

$ curl -X GET "http://localhost:8080/api/v1/customers?p=1" -H "accept: application/json"

Post example,

$ curl -X POST "http://localhost:8080/api/v1/customers" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{\"customer\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"registration\":\"2024-03-20 10:30\"}"

Put example,

$ curl -X PUT "http://localhost:8080/api/v1/customers/1234" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{\"customer\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"registration\":\"2023-03-20 10:20\"}"

Patch example,

$ curl -X PATCH "http://localhost:8080/api/v1/customers/1234" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{\"customerFirstName\":\"John\",\"customerLastName\":\"Doe\"}"

Delete example,

$ curl -X DELETE "http://localhost:8080/api/v1/customers/1234" -H  "accept: */*"```

### cURL with certificates

```bash
$ curl --cacert ca.crt --cert client.crt --key client.key https://example.com