Q:

How to retrieve dictionary data from request in python?

@app.route('/ATGDataSubmission', methods=['POST'])
def ATGDataSubmissions(): 
           print request.data //prints none
           receivedData = request.form
           print receivedData // prints ImmutableMultiDict([('ErrorMessage', u'Not able to connect'), ('SiteId', u'12345'), ('CommandResult', u'201'), ('IsSuccessfull', u'true')])//

I want to get dictionary data. What is the request method I have to use?

A:

Call to_dict on the ImmutableMultiDict:
>>> imd = ImmutableMultiDict([('ErrorMessage', u'Not able to connect'),
('SiteId', u'12345'), ('CommandResult', u'201'), ('IsSuccessfull', u'true')])
>>> imd.to_dict()
{'ErrorMessage': 'Not able to connect', 'SiteId': '12345', 'CommandResult': '201',
 'IsSuccessfull': 'true'}

