Is it possible to do a post request from browser URL

折月煮酒 提交于 2019-12-10 14:12:29

问题


I have one site e.g. www.myfirstsite.com/myapp .

When I do login in this site I did extract the POST request of authentication from the browser.

Is just a simple authentication (the authentication URL is different) process. and username and password in parameters

username = abc_user

password = 123456

and the complete URL is www.anothersite.com/login?username=abc_user&password=123456

When I do POST request using Postman I received expected result.

Is there any way (any script which I enter in URL) to do POST request from browser URL itself like GET Request to authenticate


回答1:


In your browser's URL bar, type

javascript:

and then paste the following

(function(){document.body.innerHTML='<form method="POST" action="http://www.myfirstsite.com/myapp"><input name="username" value="abc_user"/><input name="password" value="123456"/></form>';document.forms[0].submit()})();

It will insert a form with the required values in the page and then submit it.

The reason you have to type the javascript: manually, is that for security reasons, some browsers will strip it off if you paste the entire blob.

You can also create a bookmark with the contents below and use that.

javascript:(function(){document.body.innerHTML='<form method="POST" action="http://www.myfirstsite.com/myapp"><input name="username" value="abc_user"/><input name="password" value="123456"/></form>';document.forms[0].submit()})();


来源:https://stackoverflow.com/questions/42107983/is-it-possible-to-do-a-post-request-from-browser-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!