1

I've been trying to get an XML response from a Dynatrace server using REST api. I have no trouble getting an XML response when I put the url through Postman, and I am able to receive a 'text' datatype response from ajax, but not an 'xml' response. I plan to parse this data into json for future use.

The code I am using so far is:

function getXML() {
      basicAuth = "Basic " + id + ":" + password;

      $.ajaxSetup({
            async: false
      });

      $.ajax({
            type: 'GET',
            url: dynUrl, //this is the function we defined above
            dataType: 'xml',
            headers: {
                'Authorization': basicAuth //this is for basic authentication, you've already provided UID and PWD above.
            },

            //when we succeed, the function below will be called.
            success: function(respt)
            {
                  data = respt;
            }
      });
}

This is called in the following function.

function XMLRespond()
{
      getXML();
      //dom = parseXml(data);
      //json = xmlToJson(dom);
      return data;
}

data is called and displayed by an html hosted on localhost. However, when I run this, I get a blank screen and the console says "Permission Denied". My debugger gives me:

Failed to open http://localhost:8080/api/Test.html

Any help on this issue would be greatly appreciated!

Jim Wu
  • 149
  • 1
  • 8

1 Answers1

0

Solved the issue. Turns out IE (and I suspect other Browsers) can't straight up display data. Converting data to a string bypassed this problem.

Jim Wu
  • 149
  • 1
  • 8