小编Kri*_*lal的帖子

用于POST请求Python的嵌套字典到JSON

我无法以嵌套字典的形式转换有效负载数据,以使用Python请求模块将其作为POST请求的数据传递.表格数据如下:

payload = {'request':  {
                'appkey': "936725A4-7D9A-11E5-81AC-86EC8D89CD5A"},
            'formdata':{
                    'currency':'US',
                    'dataview':'store_default',
                    'distinct':'_distance, clientkey',
                    'geolocs':{
                            'geoloc':[{
                                    '0':{
                                            'address1':'',
                                            'addressline':'19128, PA',
                                            'city':'Philadelphia',
                                            'country':'US',
                                            'latitude':'40.0532987',
                                            'longitude':'-75.23040379999998',
                                            'postalcode':'19128',
                                            'province':'',
                                            'state':'PA'}}]
                            },
                    'google_autocomplete':'true',
                    'limit':'250',
                    'nobf':'1',
                    'searchradius':'15|25|50|100|250|350|450|550|650|750|850|950',
                    'true':'1',
                    'where':{'partner_reseller': {'eq':'1'}}}                    
          }

r = requests.post(url,data=simplejson.dumps(payload),headers=header)
result = simplejson.loads(str(r.content))
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决结构问题,可以指出我所写的错误.我一直收到以下错误:

{'code': 1008,
 'response': {'message': 'The submitted XML is not properly formed'}} 
Run Code Online (Sandbox Code Playgroud)

我会非常感谢你的帮助.谢谢.

python post json dictionary python-requests

2
推荐指数
2
解决办法
3481
查看次数

标签 统计

dictionary ×1

json ×1

post ×1

python ×1

python-requests ×1