Curl azure app service with AAD auth

Get token

curl -X POST -d 'grant_type=client_credentials&client_id=<APP_ID>&client_secret=<PASSWORD>&resource=https%3A%2F%2Fmanagement.azure.com%2F' https://login.microsoftonline.com/<TENANT_ID>/oauth2/token

Basic POST. application/x-www-form-urlencoded is the default

curl -X POST http://localhost:8080/data -d "param1=value1&param2=value2" 

POST json

curl -X POST http://localhost:3000/data -H "Content-Type: application/json" -d '{"key1":"value1", "key2":"value2"}' 

POST data from file. application/x-www-form-urlencoded is the default.

curl -X POST http://localhost:3000/data -d "@data.txt" 

Disable certificate validation

curl -k https://localhost:8080

Add bearer token header

curl -H 'Accept: application/json' -H "Authorization: Bearer <TOKEN>" https://bustroker.com/api/resource

New line after output

curl localhost:8080 ;echo

Pretty format json output (Linux)

curl localhost:8080 | json_pp

also, jq would do it

curl localhost:8080 | jq "."

Use jq to extract properties from json response (Linux)

-r: raw output (i.e., output with no surrounding quotes)

curl localhost:8080 | jq -r ".some.property.in_Json.tree"