Dbconnection/signup api Invalid Json response

Team,
I am trying to call /dbconnection/signup api to create a user using python code

I user the following JSON
create_user_body = {
‘client_id’: ‘MY_CLIENT_ID’,
‘email’: ‘ganesh.kumar@reflectionsinfos.com’,
‘password’: ‘S3cr3t@nopass’,
‘connection’: ‘register-user-test-conn’
}
My request headers include
request_headers = {
‘Content-Type’: ‘application/json’,
‘Authorization’: f’Bearer {token}’
}
Url I try is
"https://<MY_DOMAIN>/dbconnections/signup

I am using python requests.post like below
response = requests.post(url, data=create_user_body, headers=request_headers)

But when I post the request I get 400 response code with b"invalid Json" text. I checked password strength, db connection name e t c and they are correct. I cannot figure out what is invalid with the json. Also the token i use in the request is obtained using the /ouath/token endpoint (Client credentials Flow). Can you please help?

Regards,
Ganesh

Hi @authneumoney,

Welcome to the Auth0 Community!

I understand that you have been having trouble making a request to create a user with Python.

After my tests, I did not find the same observations as you. Instead, I was able to create a user successfully. In this case, could you please try the following code snippet for creating a user?

import http.client

conn = http.client.HTTPSConnection("YOUR_DOMAIN.REGION.auth0.com")
payload = 'client_id=YOUR_CLIENT_ID&email=sampleuser@test.com&password=Secret&connection=YOUR_CONNECTION'
headers = {
  'Content-Type': 'application/x-www-form-urlencoded'
}
conn.request("POST", "/dbconnections/signup", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Having tested this myself, I can confirm that this works.

Please let me know how this works for you.

Thank you.

Hi Rueben,
Thanks this works… :+1:

Regards,
Ganesh

1 Like