The request block can be in either XML or JSON. By default, the Content-Type
is (text/xml
). If you use XML, the block must have root element called <tsRequest>. The body of the XML request might look like the following:
<tsRequest>
<user name="Bob"
siteRole="Viewer" />
</tsRequest>
If you set the Content-Type
to JSON (application/json
), the request block might look like the following:
{
"user": {
"name": "Bob",
"siteRole": "Viewer"
}
}
The siteRole value is the role you want the new user to have, such as Viewer, Publisher, or Interactor. In response to the POST request to create a user, Tableau Server returns the response that includes the user-id
assigned to the new user.
To update a user, you make a PUT request and use a URI like the following to update the user with the specific user-id
:
http://your-server/api/3.13/sites/site-id/users/user-id
In XML, the body of the request might look like this:
<tsRequest>
<user fullName="Adam Davis"
email="adamd@example.com"
password="passw0rd" />
</tsRequest>
Or like the following in JSON:
{
"user": {
"fullName": "Adam Davis",
"email": "adamd@example.com",
"password": "passw0rd"
}
}
The XML and JSON requests and responses follow a schema. You can use the XML schema to generate classes that you can use when programming.
REST API methods that require data in the body of the request pass the data as an XML block. In addition, many API methods return data in the response using an XML block.
The schema for the XML used in requests and response is available in a schema (.xsd) file. When you construct XML for a request, you must make sure that the XML block is well formed and that it conforms to the schema. For many programming frameworks, you can generate code from the .xsd file that maps XML elements and attributes to objects and properties. You can use this code to help you create XML blocks using typed code, and to deserialize and serialize data from REST API requests and responses.
You can download the lastest schema as an .xsd file from the following locations: