How do you force a web browser to use POST when getting a url?
You cannot make a POST request by using a web browser, as web browsers only directly support GET requests. For this example, we assume that you have installed a REST client browser plugin. Chrome and Firefox both support open source Rest Client plugins that allow for the invocation of REST APIs from the browser.
POST request in itself means sending information in the body. I found a fairly simple way to do this. Use Postman by Google, which allows you to specify the content-type (a header field) as application/json and then provide name-value pairs as parameters. Just use your URL in the place of theirs.
In case of post request, large amount of data can be sent because data is sent in body. 2) Get request is not secured because data is exposed in URL bar. Post request is secured because data is not exposed in URL bar.
Type the url in the main input field and choose the method to use: GET/POST/PUT/DELETE/PATCH. Click on the arrow "Send" or press Ctrl+Enter. You'll see info about the response (time, size, type) and you'll be able to see the content response in the response section.
Use an HTML form that specifies post as the method:
<form method="post" action="/my/url/"> ... <input type="submit" name="submit" value="Submit using POST" /> </form>
If you had to make it happen as a link (not recommended), you could have an onclick handler dynamically build a form and submit it.
<script type="text/javascript"> function submitAsPost(url) { var postForm = document.createElement('form'); postForm.action = url; postForm.method = 'post'; var bodyTag = document.getElementsByTagName('body')[0]; bodyTag.appendChild(postForm); postForm.submit(); } </script> <a href="/my/url" onclick="submitAsPost(this.href); return false;">this is my post link</a>
If you need to enforce this on the server side, you should check the HTTP method and if it's not equal to POST, send an HTTP 405 response code (method not allowed) back to the browser and exit. Exactly how you implement that will depend on your programming language/framework, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With