Compatibility between Fetch API on MSOffice and API

I’ve tried to run the fastly purge IP from js(fetch api) on MS Office.
However “Failed to fetch” was returned.

So, I’ve tried to run /public-ip-list (very simple GET!) from it. It also failed.
https://httpbin.org/ip succeeded with the same code.

It has some compatibility problem between office and fastly API?
Anyone has information on this issue?

Hi @shinpei3 we don’t have any logic within Fastly that would alter an API request based on the client used, though I had no idea MS Office could make outside HTTP calls. That’s very cool!

Are you able to include the full request for a deeper review?

Hi @aspires,
Here is the code

async function main(workbook: ExcelScript.Workbook) {
    const url = `https://api.fastly.com/public-ip-list`;
    const options = {
      "method": "get",
      headers: {
          "Accept": "application/json"
      }
    }

    let response = await fetch(url,options);
    if (!response.ok) {
        throw new Error(`HTTP error! Status: ${response.status}`);
    }
    var responseData = await response.text;
}

I think you can write the code in the menu(Excel → Automize → New script)
And run it.

It gonna be “Failed to fetch”. but it’s a very simple code. I believe it doesn’t include any errors.

You’re right, @shinpei3, this is fairly straightforward. You may not need to include the options parameters, only because we try to keep that API call as flexible as possible. But that’s me grasping at a hypothesis.

Do you happen to know the User-Agent of the MSOffice calls? I can investigate if we have any sort of bot protection or security restriction that might be incorrectly triggered.

Can you show us the response status (code and reason) for this example code? Many of us here at Fastly don’t have access to Microsoft Office :slight_smile: