Not able to make HTTP Request from a TaskPane App


  • Hi,

    I am trying to call a service and retrieve JSON from that service (ñor&key=demo). Since the service doesn't support callbacks, I am not able to get the data through ajax GET. 

    When I try to do an HTTP Request, it gives me an error : Automation server can't create object

    Below is the simple code that i have attached for your reference:

      if (typeof window.ActiveXObject != 'undefined') {
                    HTTP_Response_Holder = new ActiveXObject("Microsoft.XMLHTTP");//gives error
                    HTTP_Response_Holder.onreadystatechange = process;
                else {
                    HTTP_Response_Holder = new XMLHttpRequest();
                    HTTP_Response_Holder.onload = process;
      "GET", requestUrl, true);

    Please let me know if there is another way to get JSON data from a service(with no callbacks) in Office Apps.

    Vishal Sharma

    Tuesday, April 16, 2013 4:35 PM


  • Apps for Office do not support ActiveXObjects. You should use an ajax call to make the request. If you are not using jQuery, i suggest you makes it really simple as for example:

        url: requestUrl,
        data: { parameter1: 'value', parameter2: 'value2' }, // if you need parameters
        dataType: 'jsonp', // to make sure cross domain always works...if you are using only CORS supported browsers you can also use 'json' with crossDomain: true
        success: function (data, textStatus, jqXHR) {
            // here you have result in your data parameter

    Not that the site you are trying to query might not support jsonp. If this is the case, then use dataType: 'json' and set crossDomain: true . This feature (cross domain calls with cors standard) however is not supported in IE 9 or older, but is supported in other browsers (including IE10).

    If you really need IE9, then you could preform a proxied GET request via a web service which is running on same domain.

    Anze Javornik

    Tuesday, April 16, 2013 7:24 PM