Sending data (not form) in wreq

Viewed 219

Given a curl request of the form:

curl --header "Content-Type: text/xml;charset=UTF-8" --data @somefile.xml http://httpbin.org/post

How can we do that in wreq? I confirmed through echo from httpbin that the data is sent as "data" - below is snippet from httpbin post echo:

  {
  "args": {}, 
  "data": "<file-contents here sent by curl --data option>", 
  "files": {}, 
  "form": {}, 
  "headers": {...
  ...},
  "json": null, 
  "origin": "some_ip", 
  "url": "http://httpbin.org/post"
  }

So, basically, given the data from the file as a Text or String, how do we make it Postable in wreq without using form or multi-part (unless data option of curl is just a form or multi-part post in disguise)? I am digging around wreq documentation but haven't yet found anything about that. I will very much appreciate pointers on how to do this. Setting headers and other things are pretty straight-forward in wreq as shown in the tutorial.

1 Answers
Related