Publish Custom View


🕐 4 min read

Publishes or imports a custom view associated with a workbook on the specified site. To change a published or imported custom view, call Update Custom View.

This method is used in two ways. You can call it to publish a custom view in a single request. To do that, you include the content of the custom view file in the body of the request. The maximum size of a file that can be published in a single request is 64 MB.

Alternatively, you can publish a custom view in multiple parts. To do that:

  1. Initiate a file upload by calling Initiate File Upload.
  2. Send portions of the file to the server using Append to File Upload.
  3. Commit the upload by calling Publish Custom View. In this case, Publish Custom View doesn’t contain the file to publish.

URI

POST /api/api-version/sites/site-id/customviews

POST /api/api-version/sites/site-id/customviews?uploadSessionId=upload-session-id

Parameter Values

Parameter Description
api-version The version of the API to use, such as 3.18. For more information, see REST API and Resource Versions.
site-id The ID of the site to publish to.
upload-session-id If you’re calling this method to commit a file that was uploaded in parts, this value contains the upload session ID that was generated by a call to Initiate File Upload. If this value isn’t included, the server assumes that the body of the request contains the file to be published.

Request Body

The content type in the header of requests to publish a workbook must use the mixed multipart content type with a boundary string definition, in the form of: Content-Type: multipart/mixed; boundary=boundary-string.

Publishing a file in the request body

--*boundary**-**string*
Content-Disposition: name="request_payload"
Content-Type: text/xml
<tsRequest>
    <customView name="*customview-name*" shared="*public-visibility-flag*">
        <workbook id="*workbook-luid*"/>
        <owner id="*owner-luid*" />
    </customView>
</tsRequest>
--*boundary**-**string*
Content-Disposition: name="tableau_customview"; filename="*customview**-file-name*"
Content-Type: application/octet-stream
*content**-**of**-customview**-**file*
--*boundary**-**string*--

Committing a file previously uploaded

*--boundary-string*
Content-Disposition: name="request_payload"
Content-Type: text/xml
<tsRequest>
    <customView name="*customview-name*" shared="*public-visibility-flag*">
        <workbook id="*workbook-luid*"/>
        <owner id="*owner-luid*" />
    </customView>
</tsRequest>
*--boundary-string*

Attribute Values

Attribute Value
boundary-string A string of characters that is guaranteed to be unique within the body of the request, and that is used to delimit sections of the request body. This value must be declared as a header that has this format:
Content-type: multipart/mixed; boundary=*boundary-string*  
customview-name The name to assign to the custom view when it’s saved on the server.
public-visibility-flag (Optional) Specify true to have the published custom view visible to all users with relevant view permissions; otherwise, false for visibility of the custom view limited to owner and admins. The default is false.
workbook-luid The LUID of the workbook the custom view is associated with
user-luid (Optional) The LUID of the user to be assigned as owner of the custom view. You can get the user LUID by calling Get Users on Site. If not specified, the custom view ownership is assigned to the API caller
customview-file-name The file name (including the extension) of the custom view file to upload. This attribute is used in the request body only if the request also includes the content of the custom view file. It’s not used if you’re committing a file uploaded using previous requests.
content-of-customview-file The content of the custom view file, if the request includes the file. The maximum size of a file that can be uploaded in one call is 64 MB.

Permissions

Users who are server administrators or site administrators can publish a custom view.

Response Code

201

Response Body

<tsResponse >
  <customView
    id="37d015c6-bc28-4c88-989c-72c0a171f7aa"
    name="New name 2"
    createdAt="2016-02-03T23:35:09Z"
    updatedAt="2022-09-28T23:56:01Z"
    shared="false">
      <view id="8e33ff19-a7a4-4aa5-9dd8-a171e2b9c29f" name="circle"/>
      <workbook id="2fbe87c9-a7d8-45bf-b2b3-877a26ec9af5" name="marks and viz types 2"/>
      <owner id="cdfe8548-84c8-418e-9b33-2c0728b2398a" name="workgroupuser"/>
  </customView>
</tsResponse>

Version

3.21

Errors

HTTP status Error code Condition Details
400 400000 Malformed request body The XML content in the MIME multipart request is not empty.
400 400000 Missing custom view file There’s no attachment in the request and no uploadSessionID parameter.
400 400000 Unexpected attachments The message had both an uploadSessionId parameter and an attachment, or the request body contained more than one attachment.
400 400016 Attachment file size exceeds size limit The attached custom view file exceeds the size limit of 64 MB.
400 400169 Invalid custom view file The contents of the custom view file was found to be invalid.
400 400175 Missing or invalid workbook The request payload included an workbookId but the specified workbook could not be found on the specified site.
403 403163 Insufficient publishing permission User attempting to publish the custom view caller doesn’t have sufficient permissions.
404 404015 File upload not found The file upload session ID in the uploadSessionId parameter doesn’t correspond to an existing file upload on the site.
405 405000 Invalid request method The request type was not POST.

Example

curl "http://MY_SERVER/api/3.21/sites/ \
ff2a8360-3c2b-4b05-a793-7607c602e1fb/customviews" \
-X POST -H "X-Tableau-Auth:12ab34cd56ef78ab90cd12ef34ab56cd" \
-H "Content-Type: multipart/mixed;" \
-F "request_payload=@publish-customview.xml" \
-F "tableau_customview=@MY_CUSTOMVIEW.json"

Content of publish-customview.xml

<tsRequest>
    <customView name="Test1" shared="true">
        <workbook id="a70638de-c1c6-4599-9e7d-88ad29526ac5"/>
        <owner id="43dc7cdb-ca39-4688-8520-4ac7760b843b" />
    </customView>
</tsRequest>