Skip to content

[docs/defensive code] 400003: Bad Request if you skip the authSetting attribute when creating a user #1137

Open
@dev-mkc19

Description

@dev-mkc19

Describe the bug
I try to add user to a site and receive error from API responsen, but fact user being added to the server. Unfortunately discussion from issue #990 does't help to resole the problem. More then that I sent request to server directly without using TSC library and got the same error response.

Versions
Details of your environment, including:

  • Tableau Server version 2022.1.7 (20221.22.0916.0328) 64-bit Linux
  • Python version 3.8
  • TSC library version 0.23

To Reproduce
Here's my code:

import tableauserverclient as TSC
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                    filename="tsc.log", level="DEBUG")

tableau_auth = TSC.PersonalAccessTokenAuth('debug', '<TOKEN>')
server = TSC.Server('https://tableau.<DOMAIN>.com', use_server_version=True)
server.auth.sign_in(tableau_auth)

newU = TSC.UserItem('test@<DOMAIN>.com', 'Viewer')

# add the new user to the site
newU = server.users.add(newU)

server.auth.sign_out()

Results

File ~/Documents/tsc_roject/env8/lib/python3.8/site-packages/tableauserverclient/server/endpoint/endpoint.py:147, in Endpoint.post_request(self, url, xml_request, content_type, parameters)
    146 def post_request(self, url, xml_request, content_type=XML_CONTENT_TYPE, parameters=None):
--> 147     return self._make_request(
...

ServerResponseError: 

	400003: Bad Request
		Payload is either malformed or incomplete

Direct request:

curl "https://tableau.<DOMAIN>.com/api/3.15/sites/abea43f7-3d3a-4c4a-adcf-2007aa48c888/users/" -X POST -H "X-Tableau-Auth:<TOKEN>" -d @add-user-to-site.xml

add-user-to-site.xml:

<tsRequest>
  <user name="test@<DOMAIN>.com"
    siteRole="Viewer" />
</tsRequest>

Response:

<?xml version='1.0' encoding='UTF-8'?><tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api https://help.tableau.com/samples/en-us/rest_api/ts-api_3_15.xsd"><error code="400003"><summary>Bad Request</summary><detail>Payload is either malformed or incomplete</detail></error></tsResponse>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions