Skip to content

400003: Bad Request Payload is either malformed or incomplete #990

Closed

Description

@jasonusaco

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.TableauAuth('xxx', 'xxx', site_id='xxx')
server = TSC.Server('https://prod-apnortheast-a.online.tableau.com')

server.auth.sign_in(tableau_auth)

# create new user
newU = TSC.UserItem('Mike', 'Viewer')
server.users.add(newU)

print(newU.name, newU.site_role)

I just tried to use the api to add a new user, but it returns this:

Traceback (most recent call last):
  File "D:\Application\Anaconda\envs\new_ticket_auto\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 88, in _check_status
    raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace)
tableauserverclient.server.endpoint.exceptions.ServerResponseError: 

	400003: Bad Request
		Payload is either malformed or incomplete

and the tsc.log file return:

14:58:33,309 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): prod-apnortheast-a.online.tableau.com:443
2022-02-15 14:58:35,128 - urllib3.connectionpool - DEBUG - https://prod-apnortheast-a.online.tableau.com:443 "POST /api/3.14/auth/signin HTTP/1.1" 200 360
2022-02-15 14:58:35,135 - tableau.endpoint.auth - INFO - Signed into https://prod-apnortheast-a.online.tableau.com as user with id 10c3b3f3-9630-4f5e-ba82-xxxxxxxxx
2022-02-15 14:58:35,136 - tableau.endpoint - DEBUG - request post, url: https://prod-apnortheast-a.online.tableau.com/api/3.14/sites/a48e73ae-c557-4887-b07a-yyyyyyyy/users
2022-02-15 14:58:35,136 - tableau.endpoint - DEBUG - request content: b'<tsRequest><user name="Mike" siteRole="Viewer" /></tsRequest>'
2022-02-15 14:58:36,472 - urllib3.connectionpool - DEBUG - https://prod-apnortheast-a.online.tableau.com:443 "POST /api/3.14/sites/a48e73ae-c557-4887-b07a-yyyyyyyyy/users HTTP/1.1" 400 373

Can anyone help?

Activity

  1. bcantoni commented on Feb 15, 2022

    @bcantoni
    Contributor

    @jasonusaco I believe the problem here is in the Users documentation. The docs and examples imply that the first argument should be the user's name, but in reality what it's expecting is the email address. (At least that's the case for Tableau Online sites.)

    In your example this should work instead:

    newU = TSC.UserItem('mike@example.com', 'Viewer')
    

    Could you confirm whether that works for your case? If so I'll morph this issue into a docs bug so we can get that section clarified.

  2. jasonusaco commented on Feb 16, 2022

    @jasonusaco
    Author

    @jasonusaco I believe the problem here is in the Users documentation. The docs and examples imply that the first argument should be the user's name, but in reality what it's expecting is the email address. (At least that's the case for Tableau Online sites.)

    In your example this should work instead:

    newU = TSC.UserItem('mike@example.com', 'Viewer')
    

    Could you confirm whether that works for your case? If so I'll morph this issue into a docs bug so we can get that section clarified.

    Yes, it works! Thank you

  3. added
    help wantedA user needs help, may be a mistake, a bug or a feature request
    on Feb 16, 2022
  4. bcantoni commented on Feb 16, 2022

    @bcantoni
    Contributor

    Thanks for confirming! I've created #993 as a follow-up task to clarify the docs and examples.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedA user needs help, may be a mistake, a bug or a feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions