1 Reply Latest reply on Mar 1, 2016 11:28 AM by Travis Boyle

    Help with REST call to add project permissions

    Travis Boyle

      I have been working on a Powershell implementation of the REST API using invoke-restmethod, and have been able to successfully create project, create groups, get group information, etc.  Unfortunately when I attempt to add project permissions, I keep getting error code 400000, Bad Request, pointing to an issue with my -body XML.

       

      Initially I was using a full "publisher" permission set:

      <tsRequest>

        <permissions>

          <granteeCapabilities>

            <group id="b216a799-30b9-4457-896e-a13bc421b25a" />

            <capabilities>

              <capability name="AddComment" mode="Allow" />

              <capability name="ChangeHierarchy" mode="Allow" />

              <capability name="Connect" mode="Allow" />

              <capability name="Delete" mode="Allow" />

              <capability name="ExportData" mode="Allow" />

              <capability name="ExportImage" mode="Allow" />

              <capability name="ExportXml" mode="Allow" />

              <capability name="Filter" mode="Allow" />

              <capability name="Read" mode="Allow" />

              <capability name="ShareView" mode="Allow" />

              <capability name="ViewComments" mode="Allow" />

              <capability name="ViewUnderlyingData" mode="Allow" />

              <capability name="WebAuthoring" mode="Allow" />

              <capability name="Write" mode="Allow" />

            </capabilities>

          </granteeCapabilities>

        </permissions>

      </tsRequest>

       

      but have since pared it down to the most basic permission:

      <tsRequest>

        <permissions>

          <granteeCapabilities>

            <group id="b216a799-30b9-4457-896e-a13bc421b25a" />

            <capabilities>

              <capability name="Read" mode="Allow" />

            </capabilities>

          </granteeCapabilities>

        </permissions>

      </tsRequest>

       

      and still getting the same results:

      invoke-restmethod : <?xml version="1.0" encoding="UTF-8"?>

      <tsResponse xmlns="http://tableausoftware.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://tableausoftware.com/api http://tableausoftware.com/api/ts-api-2.0.xsd">

        <error code="400000">

          <summary>Bad Request</summary>

          <detail>Payload is either malformed XML or incomplete</detail>

        </error>

      </tsResponse>

      At line:1 char:1

      + invoke-restmethod -uri $uri -method PUT -headers $headers -body $workbook

      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc

         eption

          + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

       

      Any suggestions for what I may be missing in my -Body xml causing the bad request?