3 Replies Latest reply on Nov 15, 2018 12:03 AM by Lionel Messi

    Tableau online Rest API signin - HTTP Error 405 , Method Not Allowed

    Lionel Messi

      Hi Team,

       

      I am following the sample code (Python Example for Sign In and Sign Out (JSON)) provided here: https://onlinehelp.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_auth.htm

      I filled in the server_name, user_name, password and site_url_id variables for our Tableau Online instance.

       

      server_name: I used  "online.tableau.com"

      user_name, password:I used the username and password of a local TOL admin account

      site_url_id: I used the site id string, not the site name

       

      When I run the script I receive this error: "

      requests.exceptions.HTTPError: 405 Client Error: Method Not Allowed for url: https://online.tableau.com/api/3.2/auth/signin"

       

      i also tried using TSC client, getting below error even if i am using below code available in sample examples,

       

      tableau_auth = TSC.TableauAuth('#####', '#####',site_id='######')

      server = TSC.Server('http://online.tableau.com')

      server.version = "3.2"
      #server.use_highest_version()
      with server.auth.sign_in(tableau_auth):

       

       

      error description : -

       

      tableauserverclient.server.endpoint.exceptions.ServerResponseError:

      405000: Method Not Allowed

      The HTTP method 'GET' is not supported for the given resource

       

       

      Am I missing something here? Are Post Requests not allowed on TOL?

       

      any guidance is appreciated! Thanks!

        • 1. Re: Tableau online Rest API signin - HTTP Error 405 , Method Not Allowed
          Robert Hamm
          The HTTP method 'GET' is not supported for the given resource

          This error tells you that you are sending the request as a GET request and not a POST.  The method you are trying to hit does not allow GET requests.

           

          I would check your code where you are calling the service and ensure you are sending as a POST.

          • 2. Re: Tableau online Rest API signin - HTTP Error 405 , Method Not Allowed
            Lionel Messi

            Hi,

             

            i am using post method only.

             

            req = requests.post(signin_url, json=payload, headers=headers)

            req.raise_for_status()

            • 3. Re: Tableau online Rest API signin - HTTP Error 405 , Method Not Allowed
              Lionel Messi

              hi,

               

              i am using post method only.

               

              see the complete code below

               

              import json

              import requests

               

               

              server_name = "online.tableau.com"  # Name or IP address of your installation of Tableau Server

              user_name = "####"  # User name to sign in as (e.g. admin)

              password = "####"

              site_url_id = "####"  # Site to sign in to. An empty string is used to specify the default site.

               

               

              signin_url = "http://{server}/api/3.2/auth/signin".format(server=server_name)

               

               

              payload = {"credentials": {"name": user_name, "password": password, "site": {"contentUrl": site_url_id}}}

               

               

              headers = {

                  'accept': 'application/json',

                  'content-type': 'application/json'

              }

               

               

              # Send the request to the server

              req = requests.post(signin_url, json=payload, headers=headers)

              req.raise_for_status()

               

               

              # Get the response

              response = json.loads(req.content)

               

               

              print(response)

               

               

              token = response["credentials"]["token"]

               

               

              # Get the site ID from the <site> element

              site_id = response["credentials"]["site"]["id"]

               

               

              print('Sign in successful!')

              print('\tToken: {token}'.format(token=token))

              print('\tSite ID: {site_id}'.format(site_id=site_id))