Run a query from the command line
To run an HTTL query from the command line, use the following command:
httl < method > < url > [headers] [body_format] [body]Where:
-
method- one of the HTTP methods from the list -
url- the URL to make the request, can be absolute or relative if you use along with a default .httl file -
headers- headers in the formatkey:valueseparated by space, example:Authorization:token -
body_format- body format, one of--json(default),--formdata,--urlencoded,--raw,--bin -
body- body content, example:{ name: "John" }
Examples
Simple GET request
httl get https://httl.dev/api/usersSimple GET request with a basic .httl file with content: @base: https://httl.dev/api
httl get usersGET request with headers
httl get https://httl.dev/api/users Authorization:"Bearer token" Cache-Control:privatePOST request with a JSON body
httl post https://httpbin.org/anything '{ name: "John" }'PUT request with form data; JSON payload will be converted to form data
httl put https://httpbin.org/anything --formdata '{ name: "John" }'POST request with a URL-encoded body
httl post https://httpbin.org/anything --urlencoded '{ name: "John" }'POST request with a raw body
httl post https://httpbin.org/anything 'name=John&age=30'POST request with a binary file
httl post https://httpbin.org/anything --bin ./file.binPOST request with a payload from the input stream; HTTP will automatically detect the content type.
httl post https://httpbin.org/anything < ./payload.jsonLast updated on