Skip to content

Order of elements in datasource item XML is wrong #335

Closed as not planned
Closed as not planned

Description

@Bartman0

I wrote this issue report on the community forums, (post):

I am having trouble getting a data source published through the REST API.
The resulting error is 400011: Bad Request.

If I check the request against the 3.0 REST API XSD, it is valid:

According to XML Spy at least.

I changed the request_factory.py to do this:

class DatasourceRequest(object):
def _generate_xml(self, datasource_item, connection_credentials=None, connections=None):
xml_request = ET.Element('tsRequest')
datasource_element = ET.SubElement(xml_request, 'datasource')
datasource_element.attrib['name'] = datasource_item.name

if connection_credentials is not None and connections is not None:
raise RuntimeError('You cannot set both connections and connection_credentials')

if connection_credentials:
credentials_element = ET.SubElement(datasource_element, 'connectionCredentials')
credentials_element.attrib['name'] = connection_credentials.name
credentials_element.attrib['password'] = connection_credentials.password
credentials_element.attrib['embed'] = 'true' if connection_credentials.embed else 'false'

if connection_credentials.oauth:
credentials_element.attrib['oAuth'] = 'true'

project_element = ET.SubElement(datasource_element, 'project')
project_element.attrib['id'] = datasource_item.project_id

The fix is to have the project definition come after the credentials. Before this change, the request was not valid according to the XSD.

Overall, I am trying to achieve this:

  • change database environment in the data source
  • publish the data source with changed credentials
  • I am using the document and service Python SDK's to do this

Script is attached.

datasource_publish.py.zip

Activity

  1. t8y8 commented on Sep 5, 2018

    @t8y8
    Contributor

    @irwando @RussTheAerialist the ordering of elements shouldn't matter -- this seems like a Server-side problem?

  2. Bartman0 commented on Sep 5, 2018

    @Bartman0
    Author
  3. Bartman0 commented on Feb 14, 2019

    @Bartman0
    Author
  4. jacalata commented on Nov 10, 2021

    @jacalata
    Contributor

    Order does matter in xml for elements in a sequence. I can repro this locally with newer versions of Server as well.
    https://stackoverflow.com/questions/4328867/does-xml-care-about-the-order-of-elements

  5. changed the title [-]Tableau 2018.1 server does not accept data source through REST API[/-] [+]Order of elements in datasource item XML is wrong[/+] on Nov 10, 2021
  6. t8y8 commented on Nov 10, 2021

    @t8y8
    Contributor

    DatasourceItem responses are just elements as constructed by various serializers in Server, but also whatever language you happen to use (python here) -- I don't recommend that we make order part of the API contract, it could change if the underlying java library changes how it writes data out. If you use the JSON representation your even more likely to hit different element ordering because many hash maps/dicts aren't ordered.

    If we use sequence in our XSD maybe that's incorrect and it should be something else that doesn't require ordering?

  7. bcantoni commented on Jan 14, 2022

    @bcantoni
    Contributor

    I don't believe there is anything to fix here, but will leave open to investigate that question about changing things in the XSD.

  8. jacalata commented on Feb 14, 2023

    @jacalata
    Contributor

    The xsd sequence element generates this restriction on the Java class:
    @XmlType(name = "customViewType", propOrder = {
    "view",
    "workbook",
    "owner"
    })

    however this is only expected to affect the serialized output, not the acceptable input.

    AFAICT, we could replace xs:sequence with xs:all in every case and the only effect should be removing this (not-supposed-to-exist) constraint on order of elements.

  9. 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.

  10. jacalata commented on Aug 25, 2026

    @jacalata
    Contributor

    Closing as not-planned. Reviewed in 2026: TSC's request_factory.py::DatasourceRequest._generate_xml still emits <project> before <connectionCredentials>, which doesn't match the XSD sequence the original report validated against — that hasn't changed. What has changed is that Tableau Server no longer rejects the request over element order; samples/publish_datasource.py (which exercises this exact XML with --conn-username / --conn-password) has been shipping and working in the field for years, and there have been no re-reports of a 400011 from ordering since 2019. If a strict-XSD client on the response side is running into a related mismatch, please open a fresh issue with the specific element sequence and a repro against current Server.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions