Search code examples
pythonalamofirewebapp2

How to send a dictionary through params webapp2 python?


I have a dictionary in Swift like so:

let params : [String : Any] =

["user_key": "ag1kZXZ-Z29hbC1yaXNlchELEgRVc2VyGICAgICAgIAKDA", "post_text": "Lol", "trip": ["posted_by": "", "endAddress": "", "post_text": "Lol", "startAddress": ["state": "IL", "city": "Oak Park", "address1": "6503 West North Avenue", "address2": "", "zipCode": ""], "time": "", "role": "", "eta": ""]]

When I send this in the params object of Alamofire, the webapp2 accesses the params by self.request.get('user_key') and so forth, however, it does not get the 'trip' parameter. ```self.request.get('trip') returns nothing.

How do I send this dictionary to webapp2 Request Handler?


Solution

  • To access the trip dictionary you would need to use:

    class CreateMediaPostTaskHandler(webapp2.RequestHandler): def post(self): params = self.request.params start_address_city = params['trip[startAddress][city]']