Send a request with Basic Auth

Send an HTTP request with a username and password (Basic Authentication).

curl -s -u user:password https://api.example.com/endpoint | jq .

tool
curl21 commands
tags
curlnetwork

More curl commands

  • curl -so /dev/null -w '%{http_code}' https://example.com

    Print just the response status code. Handy in scripts.

  • curl -X POST https://api.example.com/v1/items -H 'Content-Type: application/json' -d '{"name":"foo"}'

    Send a JSON payload in a POST request.

  • curl -H 'Authorization: Bearer $TOKEN' https://api.example.com/me

    Send a JWT or Bearer token in the Authorization header.

  • curl -Lv --max-redirs 5 https://example.com

    Follow up to 5 redirects and show every request and response in detail.

  • curl -sSL -o /tmp/result.json https://api.example.com/data

    Download quietly and follow redirects, but still show errors.

all 21 curl commands