none
CORS call to REST webservice from Excel add-in fails RRS feed

  • Question

  • In an Excel add-in (based on office.js instead of VSTO), I had the following code that makes a RESTful web service call.

                $.getJSON("http://jsonplaceholder.typicode.com/posts/", function (data) {
                    $("#signin-status").html(data);
                })

    When running on a standalone .html file, it worked fine and CORS just works.  However, it fails when running inside Excel add-in.  The call back "function (data)" is never called.  From fiddler, there is no trace of HTTP request to http://jsonplaceholder.typicode.com/posts/ at all.

    From reading office.js documents, CORS should just work, but it is not working for me.  Could you let me know what I missed?  Thanks!


    Thursday, January 28, 2016 1:29 PM

Answers

  • Hi,

    Any locally stored HTML file to access all other files on the disk, or communicate with any site on the Internet. It means, there is same-origin policy limitations for the file on the disk.

    To address same-origin policy limitations in Office Add-ins, you can refer to the link below:
    Addressing same-origin policy limitations in Office Add-ins

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 29, 2016 7:30 AM
    Moderator

All replies

  • Hi,

    Any locally stored HTML file to access all other files on the disk, or communicate with any site on the Internet. It means, there is same-origin policy limitations for the file on the disk.

    To address same-origin policy limitations in Office Add-ins, you can refer to the link below:
    Addressing same-origin policy limitations in Office Add-ins

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 29, 2016 7:30 AM
    Moderator
  • Hi,

    Concerning the link you have posted, there is no information at all how to simply do a web request which pulls data from a website. Like Data coffee said, it does not do anything. Didn't you Geniuses at Microsoft think of a possibility that a user has to pull data from a web service somehow? The funny thing is that if you go to Excel->Data->from web and use the interface you get your web request result but if you try to do this with a XMLhttpRequest you just get zilch! So is there no possiblity that the Excel JS API communicates with the built-in function of excel so i could finally get my data from a web service?

    Many Thanks

    Tuesday, May 22, 2018 6:48 AM