Search code examples
pythonjsonformatauth0

PYTHON AUTH0 POST REQUEST: Invalid request payload JSON format


I'm trying to build a script that auto creates users in Auth0's user API the emails i received off of another software, the print out of the email result looks like this:

{'update_id': '1570540963828', '59': '1570492800000', '16': '[email protected]'}
{'update_id': '1570540932828', '59': '1570492800000', '16': '[email protected]'}

However, when I tried to include this email result i got as an input into my http request, i get an error

{u'message': u'Invalid request payload JSON format', u'error': u'Bad Request', u'statusCode': 400}

this is what I have

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()

assuming i want all pw to be blahblahblah

any input appreciated!, i think it has somehting to do with the way I used those quotation marks.

edit: originally before i did this, i used a random email like [email protected] inside the quotation marks and it worked, but now im trying to switch it to iterative email address list, its giving me that error


Solution

  • i solved it. turns out json=data worked instead of data=data