APIs & Domo Developer

APIs & Domo Developer

Add user - Jupyter workspace - DomoTokenAuth - endpoints

Hello.

Is there any documentation to add a user in a specific instance, using DomoTokenAuth, in the Jupyter workspace? Which are the supported endpoints and verbs?

I am passing the following function but the request is receiving a bad request 400 response.

  1. def add_user(instance_token, domo_instance, new_user):
  2. url = f'https://{domo_instance}.domo.com/api/content/v3/users'
  3. headers = {'x-domo-developer-token' : instance_token}

  4. res = requests.request(method='POST',
  5. url=url,
  6. headers=headers)

  7. return res.json()

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In

Best Answers

  • Coach
    Answer ✓

    With your post request, you need to also pass in the body, which would contain the user information you're attempting to add.

    1. {"displayName":"Users Name",
    2. "detail": {"email":"email@exmaple.com"},
    3. "roleId":2}
    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Coach
    Answer ✓
    1. import requests

    2. def add_user(instance_token, domo_instance, new_user):
    3. url = f'https://{domo_instance}.domo.com/api/content/v3/users'
    4. headers = {
    5. 'x-domo-developer-token': instance_token,
    6. 'Content-Type': 'application/json'
    7. }

    8. # Example payload for the new user
    9. payload = {
    10. "name": new_user['name'],
    11. "email": new_user['email'],
    12. "role": new_user['role'] # Optional, set if needed
    13. }

    14. res = requests.request(method='POST',
    15. url=url,
    16. headers=headers,
    17. json=payload) # Send JSON payload

    18. # Check for a successful response
    19. if res.status_code == 200 or res.status_code == 201:
    20. return res.json()
    21. else:
    22. # Return the status code and error message for debugging
    23. return {"status_code": res.status_code, "error": res.text}

    24. # Example usage
    25. instance_token = 'your_instance_token'
    26. domo_instance = 'your_domo_instance'
    27. new_user = {
    28. "name": "John Doe",
    29. "email": "johndoe@example.com",
    30. "role": "Participant" # Optional, use "Admin", "Privileged" if needed
    31. }

    32. response = add_user(instance_token, domo_instance, new_user)
    33. print(response)

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

Answers

  • Coach
    Answer ✓

    With your post request, you need to also pass in the body, which would contain the user information you're attempting to add.

    1. {"displayName":"Users Name",
    2. "detail": {"email":"email@exmaple.com"},
    3. "roleId":2}
    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Coach
    Answer ✓
    1. import requests

    2. def add_user(instance_token, domo_instance, new_user):
    3. url = f'https://{domo_instance}.domo.com/api/content/v3/users'
    4. headers = {
    5. 'x-domo-developer-token': instance_token,
    6. 'Content-Type': 'application/json'
    7. }

    8. # Example payload for the new user
    9. payload = {
    10. "name": new_user['name'],
    11. "email": new_user['email'],
    12. "role": new_user['role'] # Optional, set if needed
    13. }

    14. res = requests.request(method='POST',
    15. url=url,
    16. headers=headers,
    17. json=payload) # Send JSON payload

    18. # Check for a successful response
    19. if res.status_code == 200 or res.status_code == 201:
    20. return res.json()
    21. else:
    22. # Return the status code and error message for debugging
    23. return {"status_code": res.status_code, "error": res.text}

    24. # Example usage
    25. instance_token = 'your_instance_token'
    26. domo_instance = 'your_domo_instance'
    27. new_user = {
    28. "name": "John Doe",
    29. "email": "johndoe@example.com",
    30. "role": "Participant" # Optional, use "Admin", "Privileged" if needed
    31. }

    32. response = add_user(instance_token, domo_instance, new_user)
    33. print(response)

    ** Was this post helpful? Click Agree or Like below. **
    ** Did this solve your problem? Accept it as a solution! **

  • Thanks for the information! I will authenticate using the client id-secret instead as it is better documented.

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In