Skip to content

Instantly share code, notes, and snippets.

@mlsaito
Last active June 18, 2018 07:55
Show Gist options
  • Save mlsaito/2aa1e6e7fcf226af1e92722542cc3a1f to your computer and use it in GitHub Desktop.
Save mlsaito/2aa1e6e7fcf226af1e92722542cc3a1f to your computer and use it in GitHub Desktop.
cURL Cheatsheet

cURL with Basic Authorization:

$ cURL -X POST -H "Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l" https://localhost:3000

cURL with username and password (pretty much same with Basic Auth):

$ curl -X POST -H "Content-Type: application/json" \
     --user "usernameorclient_id:passwordorclient_secret" \
     -d '{"grant_type": "client_credentials", "scope": "public"}' \

cURL with URL-encoded data:

$ cURL -X POST -d "api_key=JfdkamjTu" "secret_key=NotSoSecret" https://localhost:80

cURL with JSON data:

$ cURL -X POST -H "Content-Type: application/json" -data '{"username":"xyz","password":"xyz"}' https://localhost:3000/api/login

cURL to upload image file:

$ curl -X POST -F "image=@/yourPath/yourImageFile.jpg" https://localhost:3000/image_recognize

cURL on https localhost but with invalid cert:

$ cURL --insecure https://localhost:3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment