我正在尝试构建一个在 Auth0 的用户 API 中自动创建用户的脚本 我从另一个软件收到的电子邮件,电子邮件结果的打印结果如下所示:
{'update_id': '1570540963828', '59': '1570492800000', '16': '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e9919093a9919093c78a8684" rel="noreferrer noopener nofollow">[email protected]</a>'}
{'update_id': '1570540932828', '59': '1570492800000', '16': '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c0a1a2a380a1a2a3eea3afad" rel="noreferrer noopener nofollow">[email protected]</a>'}
但是,当我尝试将收到的电子邮件结果作为输入包含到我的 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]在引号内并且它有效,但现在我尝试将其切换到迭代电子邮件地址列表,它给了我这个错误
最佳答案
我解决了。事实证明 json=data 有效,而不是 data=data
关于Python AUTH0 发布请求 : Invalid request payload JSON format,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58310531/