小编Jef*_*oup的帖子

发送字典列表作为带有请求的字典值

我有客户端服务器应用程序。我定位了麻烦,并且有这样的逻辑:

客户:

# -*- coding: utf-8 -*-
import requests


def fixing:
    response = requests.post('http://url_for_auth/', data={'client_id': 'client_id', 
                             'client_secret':'its_secret', 'grant_type': 'password', 
                             'username': 'user', 'password': 'password'})
    f = response.json()
    data = {'coordinate_x': 12.3, 'coordinate_y': 8.4, 'address': u'\u041c, 12', 
            'products': [{'count': 1, 'id': 's123'},{'count': 2, 'id': 's124'}]}
    data.update(f)
    response = requests.post('http://url_for_working/, data=data)
    response.text #There I have an Error about which I will say later
Run Code Online (Sandbox Code Playgroud)

oAuth2运作良好。但是在服务器端,request.data中没有任何产品

<QueryDict: {u'token_type': [u'type_is_ok'], u'access_token': [u'token_is_ok'], 
             u'expires_in': [u'36000'], u'coordinate_y': [u'8.4'], 
             u'coordinate_x': [u'12.3'], u'products': [u'count', u'id', u'count', 
             u'id'], u'address': [u'\u041c, 12'], …
Run Code Online (Sandbox Code Playgroud)

python django post python-requests oauth2

0
推荐指数
1
解决办法
2369
查看次数

标签 统计

django ×1

oauth2 ×1

post ×1

python ×1

python-requests ×1