OfficeDev/office-js

Outlook Launch Event: fetch(url) TypeError: Network request failed

Closed this issue · 1 comments

All fetch API calls made from a launch event process on outlook desktop fails.

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]: PC
  • Host [Excel, Word, PowerPoint, etc.]: Outlook
  • Office version number: 2404 (Build 17531.20152)
  • Operating System: Windows
  • Browser (if using Office on the web): ______

Expected behavior

All fetch(url) API request calls should succeed and I should be able to do make use of its response.

Current behavior

All fetch(url) API request calls fails with a network failure error.

Steps to reproduce

Repo: https://github.com/teejay001/LaunchEventFetchApiFailure
Implemented 3 launch events (OnMessageSend, OnNewMessageCompose, OnMessageRecipientsChanged, OnMessageAttachmentsChanged)

  1. Open a new message, the launch event function name and event object is appended to message body
  2. Add a recipient, This fails to append function name and event object to message body (Issue is with the fetch API)
  3. Add an attachment, the launch event function name and event object is appended to message body

The API does work fine because you can open task pane and click the run button, this will fetch the data and append it to the message body

Link to live example(s)

https://github.com/teejay001/LaunchEventFetchApiFailure

Provide additional details

  1. this works fine on OWA, and new Outlook clients

Context

We need to be able to retrieve an send relevant information to API endpoint for business purposses.

Useful logs

In the classic Outlook client the launch events are run in a pure javascript engine instead of a webview browser control for performance reasons and as a result fetch isn't predefined for you. Also note that you cannot just import it to the file, but you'd have to use a bundler to combine the import into a single file for the js runtime to consume.

https://learn.microsoft.com/en-us/office/dev/add-ins/testing/runtimes#javascript-only-runtime