我正在尝试构建一个脚本,该脚本会在Auth0的用户API中自动创建用户我从其他软件收到的电子邮件,电子邮件结果的打印结果如下所示:
{'update_id': '1570540963828', '59': '1570492800000', '16': '[email protected]'}
{'update_id': '1570540932828', '59': '1570492800000', '16': '[email protected]'}
但是,当我尝试包含此电子邮件结果作为输入到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()
假设我希望所有人都成为罪魁祸首
感谢任何输入!我认为这与我使用这些引号的方式有关。
编辑:最初在执行此操作之前,我在引号内使用了诸如[email protected]之类的随机电子邮件,它可以正常工作,但是现在我试图将其切换到迭代电子邮件地址列表,这给了我这个错误
检查下面的代码段完整代码,我已经更新了行data = {"email": email, "connection":"Username-Password-Authentication","password":"blahblahblah"}.
我解决了。原来是json = data而不是data = data