web analytics

Tableau Server REST API Introduction

Options

codeling 1532 - 6399
@2021-08-31 09:28:52

With the Tableau Server REST API you can manage and change Tableau Server, Tableau Online site, and Prep Conductor resources programmatically, using HTTP. The API gives you simple access to the functionality behind Tableau data sources, projects, workbooks, site users, sites, flows, and more. You can use this access to create your own custom applications or to script interactions with Tableau resources.

@2021-09-14 09:03:08

When you work with the Tableau Server REST API, you use the following HTTP verbs to request actions from the server:

  • GET to read information, such as getting a list of users or downloading a workbook.
  • POST to create or publish new resources, such as sites, users, workbooks, and data sources.
  • PUT to update existing resources, such as updating a user’s password, updating permissions, or changing a workbook owner.
  • DELETE to remove a resource, such as deleting a user, or workbook. This verb can also dissociate a resource from a collection—for example, you can use the DELETE verb to remove a user from a site, which dissociates the user from collection of users on the site, but doesn't remove the user from the server.

The HTTP verb indicates the type of operation you want to perform on a resource. You indicate what resource to work with by making requests using a URI. The URI specifies the site, project, workbook, user, or other resource that you are creating, viewing, or deleting. For example, to get a list of the users in a specific group, you send a GET request that has the following format:

https://your-server/api/api-version/sites/site-id/groups/group-id/users

In this URI, your-server is the name or IP address for your Tableau Server installation, api-version is the api version bumber, The site-id value is an identifier for the site, and group-id is an ID for the group.

 

@2021-09-14 09:16:08

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 ViewerPublisher, 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:

Comments

You must Sign In to comment on this topic.


© 2021 Digcode.com