I need to connect to sharepoint lists in web excel for both read and write, to use excel essentially like a form where I can build smarter calculations (yes, I know powerapps/automate is a better solution, however there are some company limitations on this front). So far my script looks like this:
let bob = await getListData();
let mySheet = workbook.getActiveWorksheet();
let myCell = mySheet.getCell(1,1)
myCell.setValue(bob)
}
async function getListData(){
let dataj='test';
let headers:{};
headers ={
"method":"GET",
"credentials": "same-origin",
"headers": {
"accept": "application/json;odata=verbose",
"accept-language": "en-US,en;q=0.9",
"content-type": "application/json;odata=verbose"}
}
await fetch("https://mySite.sharepoint.com/sites/myGroup/_api/web/lists/GetByTitle('myList')/items", headers)
.then((data) => {dataj=data.statusText; console.log(dataj)});
return dataj
}
I've tested the second function in the browser console & I get the expected response, but in officescript I get 'forbidden', while if I change the credentials to 'include' I get 'failed to fetch'. Anyone got ideas?