
HTTPie: How to Send Form Data
Updated
Learn how to send form data and upload files using HTTPie

Before we start, make sure you have HTTPie installed on your computer. If you don't have it yet, you can install it with Homebrew:
brew install httpie
By default, HTTPie sends your data as JSON. To send it as a regular web form instead, open your terminal and add the -f flag:
http -f POST https://example.com/login username=alice password=secret
Just replace the URL and the key=value fields with your own. The -f flag (or --form) switches the Content-Type to application/x-www-form-urlencoded. You can even leave out POST, because HTTPie switches to POST on its own when you send data.
Upload a File
To attach a file, use the field@path syntax. HTTPie then sends the request as multipart/form-data:
http -f POST https://example.com/upload name='My Report' report@report.pdf
If an endpoint wants multipart even without a file, use --multipart instead of -f. To check what was sent, add -v and look at the request headers.
Two more tricks: 'data@file.bin;type=application/octet-stream' overrides the file's MIME type, and bio=@bio.txt (with =@) reads the file's text into a normal form field instead of uploading it.
