====== Send POST requests ======
By default, web browsers use the GET method when you enter a URL in the address bar. This means you can't directly send a POST request using the address bar of a browser. \\
However, there are several ways to send POST requests from a web browser:
===== HTML Forms =====
You can create an HTML form with method="post" which will send a POST request when the form is submitted.\\ For example:
This form sends a POST request to http://example.com/my-endpoint with **myField=Some%20data** in the request body when the Submit button is clicked.
===== JavaScript and Fetch API / XMLHttpRequest =====
You can use JavaScript in the browser to send POST requests programmatically using the Fetch API or XMLHttpRequest. \\
For example:
fetch('http://example.com/my-endpoint', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({myField: 'Some data'})
});
This code sends a POST request to http://example.com/my-endpoint with a JSON body **{ "myField": "Some data" }**.
===== Developer tools =====
You can use the browser's developer tools to send POST requests. \\
For instance, in Chrome, you can go to the Network tab of developer tools, right-click on a request and select "Copy as cURL". Then you can modify this command in the console or in a terminal window.
===== Browser extensions =====
Simplest way is to install Postman from https://www.postman.com/downloads/
\\
There are also browser extensions like RESTer, or HTTP Request Maker that provide a user interface for creating and sending POST requests.