I can't assign a role to a user

I’m trying to add a role to a user via requests in python, but I’m having problems with the data part. I’ve tried to send this data passing a pure list, using json parameter instead of data and other options…

    headers={'Authorization': 'Bearer my_token',
             'Content-Type': 'application/json'}

Following the docs, if I try to send the same data via cURL or in a client like Insomnia, it works.

curl --request PATCH \
--url 'https://{extension_url}/users/{user_id}/roles' \
  --header 'Authorization: Bearer {access_token}' \
  --header 'Content-Type: application/json' \
  --data '[ "{role_id}" ]'

Hi @yuri.costa,

Welcome to the Community!

What is the error you are getting?

Also, we have an auth0 python library that could be helpful

1 Like

If I use data=json.dumps(["my_role_id"]) or json=["my_role_id"] I don’t get any errors, only the status code 204, but it doesn’t assign the role the user.

Are you seeing a successful log in your dashboard?

1 Like

Yes, I am. All the keys and tokens are right too. I also call other endpoints via requests normally.

1 Like

Would you DM me your tenant name?

I am going to mark this resolved. Please open another ticket if the issue persists.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.