question

AlanLeMarquand-3255 avatar image
0 Votes"
AlanLeMarquand-3255 asked AlanLeMarquand-3255 published

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?

office-addins-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers