Skip to content

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

Closed

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>

Activity

  1. dev-mkc19 commented on Oct 28, 2022

    @dev-mkc19
    Author

    Found the clue! In my case attribute auth_setting is required. So the code should looks like

    newU = TSC.UserItem('test@.com', 'Viewer', auth_setting='ServerDefault')

    bcantoni I suppose misunderstanding from my side was because of documentation marks auth-setting attribute as an optional and TSC library doesn't raise the error also.

  2. bcantoni commented on Oct 28, 2022

    @bcantoni
    Contributor

    Thanks for the detailed report. I'll double-check that and update the documentation to be more clear.

  3. changed the title [-]400003: Bad Request Payload is either malformed or incomplete[/-] [+][docs/defensive code] 400003: Bad Request if you skip the authSetting attribute when creating a user[/+] on Feb 15, 2023
  4. mohitbhandari37 commented on Mar 20, 2023

    @mohitbhandari37

    @bcantoni Adding serverDefault to the request header does not work, we received the same error i.e.

    400003: Bad Request
    	Payload is either malformed or incomplete
    

    while adding the user.

    Below is the request -

    Do we need to add any more details in request ?

    Note - we are logged in as Server Admin while creating user.

  5. jacalata commented on Mar 25, 2023

    @jacalata
    Contributor

    What kind of user management/auth does the server have? Local users, or Active Directory, or something else?

  6. keidikapllani commented on May 18, 2023

    @keidikapllani

    I had the same issue, had to pass TableauIDWithMFA in auth_setting . Not sure if this helps anyone, but it seems to be required for Tableau Cloud instance.

  7. github-actions commented on Aug 18, 2026

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. If this is still relevant, please comment to keep it open.

  8. jacalata commented on Aug 25, 2026

    @jacalata
    Contributor

    Closing — the docs clarification promised in this thread has landed. Users.add() docstring now spells out that auth_setting is required for Tableau Cloud and documents the 400003 payload error with the TableauIDWithMFA remediation (tableauserverclient/server/endpoint/users_endpoint.py:256-292). TSC can't Python-side reject a missing auth_setting without knowing the target is Cloud, so the doc fix is the delivered resolution here. Please open a fresh issue if you hit this on a current TSC version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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