1 Reply Latest reply on Jan 3, 2018 4:21 PM by Michael Kovner

    REST API Authentication from Postman vs Web App

    Ashish Jain

      I am trying to perform some actions on the Tableau server via REST API for which I require the Auth token. I tried using the signin API from Postman and it works like a charm. However the same code is giving "Bad Request" error whe tried calling from javacript code from my webpage.

       

           var dataVal = {

                      "credentials": {

                          "name": "admin",

                          "password": "admin",

                          "site": {

                              "contentUrl": "MySite"

                          }

                      }

                  };

       

      $.ajax({

                      contentType: 'application/json',

                      data: JSON.stringify(dataVal),

                      dataType: 'jsonp',

                      success: function (data) {

                          console.log("call succeeded");

                      },

                      error: function (request, textStatus, errorThrown) {

                          console.log(request.getAllResponseHeaders());

                      },

                      processData: false,

                      type: 'POST',

                      url: 'http://mytableauserver/api/2.6/auth/signin'

                  });

       

      The above code return token, siteid, userid from postman but return ""BAD REQUEST" error from javascript code. Any pointers will be highly appreciated.