Adding Headers to Fetch POST request in Desktop Add-in event-activation
I'm developing an Add-in for Outlook Desktop and want to call my service during the OnNewMessageCompose event.
I'm using fetch like this. I'm posting to the my service with a token and a body
const result = await fetch('https://myservice.com/endpoint', {
mode: 'cors',
method: 'POST',
headers: {
'Content-Type' : 'applications/json',
'Authorization': 'Bearer : token'
},
body: JSON.stringify(body)
});
When the add-in runs within the web version of Outlook, it's fine. When run in the Desktop. it fails. A similar issue was reported regarding Excel Custom functions and the solution was to use the Sharedruntime. That does not appear to be available in Outlook. If I take out the headers it's fine, but ideally I need those to authorize against the service. Is there a way to pass custom headers via a POST in the Desktop version of an add-in?