Describe the bug
I am trying to create or modify a user, and I have not been able to. I receive different error.
Versions
Details of your environment, including:
Tableau Server version 2023.1.4
Python version 3.10.6
TSC library version: 0.25
To Reproduce
I am running two codes:
Code 1 Creating User
import tableauserverclient as TSC
TOKEN_NAME = "tokenname"
TOKEN = "S4dD5AVINzA==:aQp3EPJy09Cf3d"
SERVER_NAME = 'https://www.yourserver.com/'
SITE_NAME = 'yoursitename'
tableau_auth = TSC.PersonalAccessTokenAuth(TOKEN_NAME,TOKEN,SITE_NAME)
server = TSC.Server(SERVER_NAME, use_server_version=True)
with server.auth.sign_in(tableau_auth):
print("Signed in")
# create a new user_item
user1 = TSC.UserItem('temp', 'Viewer')
# add new user
user1 = server.users.add(user1)
print(user1.name, user1.site_role, user1.id)
# modify user info
user1.name = 'Laura'
user1.fullname = 'Laura Rodriguez'
user1.email = 'laura@example.com'
# update user
server.users.update(user1)
print("Updated user info:")
print(user1.name, user1.fullname, user1.email, user1.id)
# Sign out
server.auth.sign_out()
Code 2 Modifying User
import tableauserverclient as TSC
TOKEN_NAME = "tokenname"
TOKEN = "S4dD5AVINzA==:aQp3EPJy09Cf3d"
SERVER_NAME = 'https://www.yourserver.com/'
SITE_NAME = 'yoursitename'
tableau_auth = TSC.PersonalAccessTokenAuth(TOKEN_NAME,TOKEN,SITE_NAME)
server = TSC.Server(SERVER_NAME, use_server_version=True)
NEW_DOMAIN = '@newdomain.com'
with server.auth.sign_in(tableau_auth):
print("Signed in")
for t in TSC.Pager(server.users):
if t.site_role != "ServerAdministrator":
email = t.email
new_email = email.split("@")[0] + NEW_DOMAIN
t.email = new_email
server.users.update(t)
# Sign out
server.auth.sign_out()
ResultsFor Code 1: User is created, but code exits with error
Traceback (most recent call last):
File "D:\Tableau Server\Todos\REST API\Update email\Create User.py", line 17, in
server.users.add(user1)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 205, in wrapper
return func(self, *args, **kwargs)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\users_endpoint.py", line 77, in add
server_response = self.post_request(url, add_req)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 162, in post_request
return self._make_request(
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 87, in _make_request
self._check_status(server_response, url)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 102, in _check_status
raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace, url)
tableauserverclient.server.endpoint.exceptions.ServerResponseError:
400003: Bad Request
Payload is either malformed or incomplete
For Code 2:
Traceback (most recent call last):
File "D:\Tableau Server\Todos\REST API\Update email\Change_email.py", line 18, in
server.users.update(t)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 205, in wrapper
return func(self, *args, **kwargs)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\users_endpoint.py", line 54, in update
server_response = self.put_request(url, update_req)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 152, in put_request
return self._make_request(
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 87, in _make_request
self._check_status(server_response, url)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 102, in _check_status
raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace, url)
tableauserverclient.server.endpoint.exceptions.ServerResponseError:
400012: Bad Request
There was a problem updating user '0bfd16b9-97bf-492e-a92a-ec9b87b31cd1'.
NOTE: Be careful not to post user names, passwords, auth tokens or any other private or sensitive information.
Describe the bug I am trying to create or modify a user, and I have not been able to. I receive different error.
Versions Details of your environment, including:
To Reproduce I am running two codes: Code 1 Creating User
Code 2 Modifying User
Results For Code 1: User is created, but code exits with error Traceback (most recent call last): File "D:\Tableau Server\Todos\REST API\Update email\Create User.py", line 17, in
server.users.add(user1)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 205, in wrapper
return func(self, *args, **kwargs)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\users_endpoint.py", line 77, in add
server_response = self.post_request(url, add_req)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 162, in post_request
return self._make_request(
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 87, in _make_request
self._check_status(server_response, url)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 102, in _check_status
raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace, url)
tableauserverclient.server.endpoint.exceptions.ServerResponseError:
For Code 2: Traceback (most recent call last): File "D:\Tableau Server\Todos\REST API\Update email\Change_email.py", line 18, in
server.users.update(t)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 205, in wrapper
return func(self, *args, **kwargs)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\users_endpoint.py", line 54, in update
server_response = self.put_request(url, update_req)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 152, in put_request
return self._make_request(
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 87, in _make_request
self._check_status(server_response, url)
File "D:\Python\Python310\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 102, in _check_status
raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace, url)
tableauserverclient.server.endpoint.exceptions.ServerResponseError:
NOTE: Be careful not to post user names, passwords, auth tokens or any other private or sensitive information.