Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML form submit giving 400 bad request
    text
    copied!<p>I'm submitting a HTML form to REST(eXist db) web service using POST method.A normal submission is giving <strong>400 bad request</strong></p> <p>Here is my HTML code</p> <pre><code>&lt;html&gt; &lt;script type="text/javascript"&gt; /* function createXMLHttpRequest() { if( typeof XMLHttpRequest == "undefined" ) XMLHttpRequest = function() { try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {} try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {} try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {} try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {} throw new Error( "This browser does not support XMLHttpRequest." ) }; return new XMLHttpRequest(); } var AJAX = createXMLHttpRequest();*/ function submitForm() { //AJAX.open("POST",'http://localhost:8899/exist/rest/db/xql/sample.xq'); // AJAX.send(document.form.xmlData.value); document.form.submit(); }; &lt;/script&gt; &lt;head&gt; &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt; &lt;/head&gt; &lt;body&gt; &lt;form name='form' action="http://localhost:8899/exist/rest/db/xql/sample.xq" enctype="text/plain" method="post"&gt; &lt;input type="text" name="xmlData"/&gt; &lt;input type="button" value="Submit" onclick="submitForm()";&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The commented code is to send POST request using AJAX. I captured the http header request and response for form submit and AJAX submit These are the request headers:</p> <p>HTML form submit header:</p> <pre><code>(Request-Line) POST /exist/rest/db/xql/sample.xq HTTP/1.1 Host localhost:8899 User-Agent Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip, deflate Connection keep-alive Content-Type text/plain Content-Length 26 </code></pre> <p>AJAX request header:</p> <pre><code>(Request-Line) POST /exist/rest/db/xql/sample.xq HTTP/1.1 Host localhost:8899 User-Agent Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip, deflate Connection keep-alive Content-Length 16 Content-Type text/plain; charset=UTF-8 Origin null Pragma no-cache Cache-Control no-cache </code></pre> <p>Im not getting what's wrong in my code . Im working on this for 2 days but i din't find any solution. Please look into this and provide a solution.</p> <p>Thanks in advance. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload