Note that there are some explanatory texts on larger screens.

plurals
  1. POFlask or Werkzeug/0.9.4 breaking POST data
    primarykey
    data
    text
    <p>I have found some behaviour of Flask-restful caused I think by Werkzeug/0.9.4 that I do not understand. It seems that the use of Multidict is breaking my data when I try to POST valid JSON that contains a "=".</p> <p>Here's my test JSON:</p> <pre><code>{ "alert": { "@id": "90", "action": "hoojimaflip", "fruit": { "@bowl": "bananas", "@protocol": "tcp" }, "url": "https://this-is-a-sample/paramer?id=90" } } </code></pre> <p>Here is the POST method.</p> <pre><code>def post(self): f1=open("./log", 'w+') data = request.json if not data: # I know this is not equivalent to the JSON above. # Just troubleshooting by dumping it all out. data = request.form print &gt;&gt;f1, data return ('', 201) </code></pre> <p>If I POST using cURL with application/json it's fine. I get the POSTed JSON correctly in request.data. I will need to render it back to JSON later, but no issue.</p> <pre><code>{ u'alert': { u'@id': u'90' u'action': u'hoojimaflip', u'fruit': { u'@bowl': u'bananas', u'@protocol': u'tcp' }, u'url': u'https://this-is-a-sample/paramer?id=90', } } </code></pre> <p>If I post via cURL with application/x-www-form-urlencoded, then I should be able to get the data in request.form. But, it seems that something is breaking my data.</p> <pre><code>ImmutableMultiDict([(' { "alert": { "@id": "90", "action": "hoojimaflip", "fruit": { "@bowl": "bananas", "@protocol": "tcp" }, "url": "https://this-is-a-sample/paramer?id', u'90" } }' )]) </code></pre> <p>The "=" sign is being used as some kind of record separator and breaking the POSTed JSON.</p> <p>Does anyone have any ideas? Am I missing something obvious?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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