I have a Power Automate flow that is triggered by receiving an HTTP request. I have an Excel worksheet that has that URL inside and I want to have a button to click and send it. I created an Office Script that would grab that URL and send the request, and the script works fine when I have it saved on my OneDrive, but due to my organization sharing restrictions I cannot add a button when the script is on OneDrive. So, I saved a copy of the script on SharePoint and was able to add a button to my worksheet. It is the exact same script, but when I try to run it, it fails to send the http request.
Here is my Office Script Code:
function main(workbook: ExcelScript.Workbook) {
let httpRequest = new XMLHttpRequest();
let myPath = workbook.getActiveWorksheet().getRange("B2").getText();
httpRequest.open("GET", myPath, false);
}
And here is the error (I have not shared the actual URL, but it does work fine, I have verified it many times):
Line 6: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://myURLisHere'
If I add in some error handling and change the request to asynchronous so it will complete it fails with httpRequest.status of 0, which doesn't tell me anything.
What am I missing about saving the Office Script on Sharepoint that is not allowing the http request to send?