4 Replies Latest reply on Feb 11, 2019 1:53 AM by David Duffy

    Unable to return user favorites via Tableau REST API.

    David Duffy

      I'm using the Tableau REST API via C# to try and get a list of users favorites.

      I know the user has some, because its me.

      I have tried using API Version 2.8,3.0, 3.1 and 3.2 with little to no joy.

       

      2.8 and 3.0 respond with

      <?xml version='1.0' encoding='UTF-8'?>

      <tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-2.8.xsd"> (3.0.xsd when using API Version 3.0)

           <favorites/> (There should be a plethora of favorites of all varieties in here.)

      </tsResponse>

       

      3.1 and 3.2 give me a (404) Not found.

      The code i have in c# is:

       

              public static string QueryFavourites(string APIVersion, string AuthToken, string SiteID, string UserID)

              {

           string result = "";

                  try

                  {

                      string url = $@"{Server}/api/{APIVersion}/sites/{SiteID}/favorites/{UserID}";

       

       

                      // Create the web request 

                      WebRequest request = WebRequest.Create(url) as WebRequest;

                      request.PreAuthenticate = true;

                      request.Headers.Add($"x-tableau-auth: {AuthToken}");

       

       

                      // Get response 

                      using (WebResponse response = request.GetResponse())

                      {

                          // Get the response stream 

                          StreamReader reader = new StreamReader(response.GetResponseStream());

       

       

                          // Read the whole contents and return as a string 

                          result = reader.ReadToEnd();

                      }

                      return result;

                  }

                  catch(Exception E)

                  {

                      logger.Error("Error! System Says: " + E.Message);

                      return result;

                  }

      }

       

      does anyone know if its an issue on the tableau end or on my end?

      Is anyone able to get a list of favorites for a user?

        • 1. Re: Unable to return user favorites via Tableau REST API.
          Carisa Chang

          Hi David,

           

          What is the version of Tableau Server you are making calls against? That should tell us the correct version number.

           

          Are you sure your user exists on the specific site you are requesting favorites for? If you issue the call directly with the absolute url, do you get the expected response?

          1 of 1 people found this helpful
          • 2. Re: Unable to return user favorites via Tableau REST API.
            David Duffy

            Tableau Server Version 2018.1.1 (20181.18.0510.1418)

            The user definitely exists, i was searching for me. I definitely have favorites on the site that i am searching on (Default)

            When i run the URL using POSTMAN, i get blank favorites using version 2.8 and 3.0 (the response outlined above) and no errors.

            When i run using version 2.9, 3.1, 3.2 i get the following response:

             

            <errorcode="404001">

                 <summary>Resource Not Found</summary>

                 <detail>Version '3.1' is not a valid version of the API.</detail>

            </error>

            • 3. Re: Unable to return user favorites via Tableau REST API.
              David Duffy

              Had this question on here and Stack Overflow for a month now, even tried emailing support, no answers from anyone (not even a reply from support).

              Has anyone actually used the "Get Favorites for User" API call (successfully or not)?  if so, what version of the API were you using? what version of Tableau were you running? Does this actually work? Is anybody out there?

              Thank you

              • 4. Re: Unable to return user favorites via Tableau REST API.
                David Duffy

                Finally found out what was happening.

                It doesn't work as intended.

                It will only return user favorites for the user that is authenticated in the authentication token, regardless of what user id you put in the request.

                Had a call with Tableau support and accidentally figured it out, when we switched authenticated user.

                I will leave this here in case anyone else comes across the same issue.