Adding Headers to Fetch POST request in Desktop Add-in event-activation

Alan Le Marquand 1 Reputation point

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('', {
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?

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,649 questions
0 comments No comments
{count} votes