I have the following HTML and I want to extract the value from the input with a name equal to code, using insomnia.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Return</title>
<script>
window.onload=function() {
var form = document.getElementById("redirect_form");
form.submit();
}
</script>
<SCRIPT type="text/javascript">
/*<![CDATA[*/
document.cookie = "IV_JCT=%2Foauth; path=/;secure";
/*]]>*/
</SCRIPT>
</head>
<body>
<p>Return....</p>
<form id="redirect_form" name="redirect_form" action="https://example.com/login/callbackmfe" method="POST">
<input type="hidden" name="code" value="yDCKqoCgXDAEdeY2d01ln43gaHerP2" />
<input type="hidden" name="iss" value="https://example.com" />
<input type="hidden" name="state" value="testing" />
</form>
</body>
</html>
I've already tried several ways:
/html/body/input[@name='code']/@value OR (//input[@name='code'])[1]/@value
What would you be doing wrong?
Insomnia Version
Version: Insomnia 2023.2.2 V8: 10.8.168.20-electron.0
It is Insomnia defect. the
<html>tag need<!DOCTYPE>Declaration. If have no!DOCTYPEcan't parse.Your HTML tag missing
!DOCTYPEInsomnia recognized HTML tag
demo server
Save as
server.jsInstall dependencies
Run Server
Call by Insomnia
Parsing HTML by Insomnia
Detail steps in here
XPath
I am using this version. I hope to fix in the next version.
Note
Postman can do by this
Testsscript