title: How can I simulate a web page form submit with a Python code-behind?
body: <p>I have a critical issue. I would like integrate my application with another much older application. This service is simply a web form, probably behind a framework (I think <a href="http://en.wikipedia.org/wiki/Active_Server_Pages" rel="nofollow">ASP Classic</a> maybe). I have an action URL, and I have the HTML code for replicating this service.</p>
  
  <p>This is a piece of the old service (the HTML page):</p>
  
  <pre><code>&lt;FORM method="POST"
      url="https://host/path1/path2/AdapterHTTP?action_name=myactionWebAction&amp;NEW_SESSION=true"
      enctype="multipart/form-data"&gt;
  
      &lt;INPUT type="text" name="AAAWebView-FormAAA-field1" /&gt;
      &lt;INPUT type="hidden" name="AAAWebView-FormAAA-field2" value="" /&gt;
      &lt;INPUT type="submit" name="NAV__BUTTON__press__AAAWebView-FormAAA-enter" value="enter" /&gt;
  &lt;/FORM&gt;
  </code></pre>
  
  <p>My application should simulate form submission of this old application from <a href="http://en.wiktionary.org/wiki/code-behind" rel="nofollow">code-behind</a> with Python. For now, I didn't have so much luck.</p>
  
  <p>For now I do this</p>
  
  <pre><code>import requests
  payload = {'AAAWebView-FormAAA-field1': field1Value, \
      'AAAWebView-FormAAA-field2': field2Value, \
      'NAV__BUTTON__press__AAAWebView-FormAAA-enter': "enter"
  }
  url="https://host/path1/path2/AdapterHTTP?action_name=myactionWebAction&amp;NEW_SESSION=true"
  headers = {'content-type': 'multipart/form-data'}
  r = requests.post(url, data=payload, headers=headers)
  print r.status_code
  </code></pre>
  
  <p>I receive a 200 HTTP response code, but if I click on submit button on the HTML page, the action saves the values, but my code does not do the same. How do I fix this problem?</p>
  
  <hr>
  
  <p>The owner of an old application sent me this Java exception log. Any ideas?</p>
  
  <pre><code>org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
  </code></pre>