title: Robot Framework POST Request using RequestsLibrary passing wrong arguments
body: <p><strong>Context</strong></p>
  
  <p>Using the RequestsLibrary to automate tests for sending XML Post Requests to a server and receiving a Response which should be validated.</p>
  
  <p>The test currently Gets the 'payload' of an XML file and attempts to pass this as the 'data' argument for a Post Request. </p>
  
  <p><strong>The error</strong></p>
  
  <p>Using the RequestsLibrary on Robot Framework, the POST request continually leads to</p>
  
  <pre><code>&lt;Response [500]&gt;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Page can either not be found or displayed. &lt;br /&gt;
  Please try again or return to login.
  </code></pre>
  
  <p>within the repsonse body.</p>
  
  <p><strong>The problem</strong></p>
  
  <p>The response code we're looking for is of course 200 however 500 is continually received. Hence the response body contains </p>
  
  <pre><code>Page can either not be found or displayed. &lt;br /&gt;
  Please try again or return to login.
  </code></pre>
  
  <p>and not the required XML response, something like</p>
  
  <pre><code>&gt;&lt;MsgType&gt;ERROR&lt;/MsgType&gt;
  &lt;MsgData&gt;&amp;lt;ERROR&amp;gt;&amp;lt;CODE&amp;gt;0110&amp;lt;/CODE&amp;gt;&amp;lt;MSGTXT&amp;gt;Encryption 
  Failure&amp;lt;/MSGTXT&amp;gt;&amp;lt;/ERROR&amp;gt;&lt;/MsgData&gt;&lt;/ProcessMsgResult&gt;
  &lt;/ProcessMsgResponse&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>which should be the sort of response for an invalid request.</p>
  
  <p><strong>The Code</strong></p>
  
  <pre><code>Post request XML payload
      Disable Warnings
      Create Session    Gateway    https://URLHERE    debug=3
      ${file_data}=    Get Binary File    ${CURDIR}${/}text.xml
      &amp;{headers}=    Create Dictionary    Content-Type    text/xml
      ${resp}=    Post Request    Gateway    /post    data=${file_data}    headers=${headers}
      Log    ${resp.text}
      Log    ${resp.status_code}
      Should Be Equal As Strings    ${resp.status_code}    200
  </code></pre>
  
  <p>This is the code I am running with the Post Request arguments for <code>data</code> as <code>${file_data}</code> and <code>headers</code> as <code>${headers}</code>. <strong>However, from the test run report, the  <code>${file_data}</code> isn't being passed down correctly to the Post Request Keyword because it's using the <code>&lt;text/xml&gt;</code> as the data argument and not <code>${file_data}</code></strong></p>
  
  <pre><code>INFO : Post Request using : alias=Gateway, uri=/post, data=&lt;text/xml&gt;, headers={u'Content-Type': u'text/xml'}, files=None, allow_redirects=True
  </code></pre>
  
  <p>This is where the problem lies, and I'm not sure why for the data argument it's always <code>data=&lt;text/xml&gt;</code>. </p>
  
  <p><strong>Question</strong></p>
  
  <p><strong>Has anyone encountered this issue before of the argument not being passed down correctly?</strong> As I believe it should be <code>data=&lt;${file_data&gt;</code>, the 500 response would no longer be received because the server would receive an understandable XML request. </p>