The most commonly used tool to perform HTTP requests is curl. It's a command-line tool with a boatload of parameters. Some of the most useful ones are as follows:
- --request <METHOD> (or -X) sets the HTTP method to use
- --header "Header: Value" (or -H) sets an extra header to the request
- --data <data> (of -d) sets a body to a request, and uses @filename as a data value to attach the contents of a file
- --form "field=value" (or -F) sets a field of a form
- --cookie <file> (or -b) sets a file with cookies to send
- --cookie-jar <file> (or -c) sets a file with cookies to store
For example, if you want to send a request with a JSON file, use the following command:
curl -X POST -H "Content-Type: application/json" -d @file.json http://localhost:8080/upload
Or, to send a form, use the following command:
curl -X POST -F login=user -F password=secret http://localhost:8080/register
If you want to keep cookies between calls, use the same file to read and write cookie values with the following code: -b session.file -c session.file.
If you prefer to use GUI tools, you can consider using Postman.