PYTHON AUTH0 POST REQUEST:无效的请求负载 JSON 格式
PYTHON AUTH0 POST REQUEST: Invalid request payload JSON format
我正在尝试构建一个自动在 Auth0 的用户中创建用户的脚本 API
我从另一个软件收到的电子邮件,电子邮件结果的打印结果如下所示:
{'update_id': '1570540963828', '59': '1570492800000', '16': 'xyz@xyz.com'}
{'update_id': '1570540932828', '59': '1570492800000', '16': 'abc@abc.com'}
但是,当我尝试将此电子邮件结果包含在我的 http 请求中作为输入时,出现错误
{u'message': u'Invalid request payload JSON format', u'error': u'Bad Request', u'statusCode': 400}
这就是我的
for r in response:
#print r
email = str(r['16'])
data = '{"email":' + email +',connection":"Username-Password-Authentication","password":"blahblahblah"}'
res = requests.post(url="https://xxxxx.auth0.com/api/v2/users", data=data, headers=headers)
print res.json()
假设我希望所有 pw 都是 blahblahblah
感谢任何输入!我认为这与我使用这些引号的方式有关。
编辑:最初在我这样做之前,我在引号内使用了一个像 sjd@shd.com 这样的随机电子邮件并且它有效,但现在我试图将它切换到迭代电子邮件地址列表,它给了我那个错误
检查下面的片段完整代码,我已经更新行 data = {"email": email, "connection":"Username-Password-Authentication","password":"blahblahblah"}.
import requests
response = [{'update_id': '1570540963828', '59': '1570492800000', '16': 'xyz@xyz.com'},{'update_id': '1570540932828', '59': '1570492800000', '16': 'abc@abc.com'}]
for r in response:
headers = {}
email = str(r['16'])
data = {"email": email, "connection":"Username-Password-Authentication","password":"blahblahblah"} # updated line
res = requests.post(url="https://xxxxx.auth0.com/api/v2/users", data=data, headers=headers)
print(res.json())
我解决了。事实证明 json=data 有效而不是 data=data
我正在尝试构建一个自动在 Auth0 的用户中创建用户的脚本 API 我从另一个软件收到的电子邮件,电子邮件结果的打印结果如下所示:
{'update_id': '1570540963828', '59': '1570492800000', '16': 'xyz@xyz.com'}
{'update_id': '1570540932828', '59': '1570492800000', '16': 'abc@abc.com'}
但是,当我尝试将此电子邮件结果包含在我的 http 请求中作为输入时,出现错误
{u'message': u'Invalid request payload JSON format', u'error': u'Bad Request', u'statusCode': 400}
这就是我的
for r in response:
#print r
email = str(r['16'])
data = '{"email":' + email +',connection":"Username-Password-Authentication","password":"blahblahblah"}'
res = requests.post(url="https://xxxxx.auth0.com/api/v2/users", data=data, headers=headers)
print res.json()
假设我希望所有 pw 都是 blahblahblah
感谢任何输入!我认为这与我使用这些引号的方式有关。
编辑:最初在我这样做之前,我在引号内使用了一个像 sjd@shd.com 这样的随机电子邮件并且它有效,但现在我试图将它切换到迭代电子邮件地址列表,它给了我那个错误
检查下面的片段完整代码,我已经更新行 data = {"email": email, "connection":"Username-Password-Authentication","password":"blahblahblah"}.
import requests
response = [{'update_id': '1570540963828', '59': '1570492800000', '16': 'xyz@xyz.com'},{'update_id': '1570540932828', '59': '1570492800000', '16': 'abc@abc.com'}]
for r in response:
headers = {}
email = str(r['16'])
data = {"email": email, "connection":"Username-Password-Authentication","password":"blahblahblah"} # updated line
res = requests.post(url="https://xxxxx.auth0.com/api/v2/users", data=data, headers=headers)
print(res.json())
我解决了。事实证明 json=data 有效而不是 data=data