logo
search
Others

How to Fix Office Scripts Basic Authentication Fetch Request Fails

Maira MehtabMaira Mehtab Sep 22, 2026 869 views

Question details

The user needs to resolve an issue where an Office Script fails to execute a GET request to an external endpoint using Basic Authentication.

Product
Microsoft Excel (Office Scripts)
Device & OS
not provided
Scenario
Executing a fetch request via an Office Script to connect to a Postman Echo endpoint using a Basic Authentication header.
Observed behavior
The fetch request fails to complete successfully despite the Basic Authentication header being present in the code.
Before you start

Verify that your API endpoint allows external cross-origin requests (CORS) and ensure your Basic Authentication credentials (username and password) are accurately encoded in Base64 format.

Solution 1Recommended

Consult the Microsoft Q&A Office Development Community

Because Office Scripts operate in a restricted cloud environment, complex fetch header issues are best reviewed by dedicated developer specialists.

Office Scripts execute within a strict security boundary. Certain external fetch requests, especially those utilizing custom headers like Basic Authentication, may be blocked due to CORS (Cross-Origin Resource Sharing) policies or preflight request restrictions enforced by the cloud environment.

1
Navigate to Microsoft Q&A

Open your web browser and go to the official Microsoft Q&A website.

2
Select the Office Development Tag

Search for and select the 'Office Development' tag, which connects you directly with developers and Microsoft specialists.

3
Create a New Thread

Click 'Ask a question' to start a new thread. Clearly describe your issue, include your sanitized fetch code snippet, and mention the specific endpoint (e.g., Postman Echo) you are trying to reach.

4
Collaborate on a Solution

Wait for a specialist to review your authentication headers and endpoint configuration to determine if a workaround is required for the Office Scripts environment.

Security Precaution: Never share your actual Base64-encoded authentication string or raw credentials in public forums. Always use placeholder text (e.g., 'Basic [YOUR_TOKEN]') when posting code snippets.
Free Microsoft Office alternative

Try WPS Office for Seamless Spreadsheet Management

If strict cloud scripting limitations are slowing down your workflow, consider switching to WPS Office. WPS Spreadsheet offers a robust, local JS Macro environment for automation without the restrictive cloud fetch limitations often found in other web-based scripting tools.

  1. 1. Download WPS Office: Visit the official WPS website and download the free WPS Office suite for your operating system.
  2. 2. Open Your Spreadsheets: Launch WPS Spreadsheet and open your existing .xlsx files directly without losing any formatting or data.
  3. 3. Explore Local Automation: Navigate to the 'Tools' tab and select 'JS Macro' to start writing automation scripts within a more flexible local execution environment.
Highly compatible with Microsoft Excel (.xlsx, .xls, .csv) formatsBuilt-in JS Macros for local, secure, and efficient spreadsheet automationFree, lightweight, and uses minimal system resourcesFamiliar user interface requiring zero learning curve for traditional Office users
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Office Script fetch request fail with Basic Authentication?

Office Scripts run in a secure cloud environment that heavily restricts Cross-Origin Resource Sharing (CORS). If the external endpoint does not explicitly allow your request headers during the preflight (OPTIONS) check, the script environment will block the fetch.

Can I use external APIs in Office Scripts?

Yes, you can use the standard JavaScript `fetch` API to call external web services. However, you are limited to APIs that correctly support CORS and permit the specific HTTP methods and headers you are sending.

How do I correctly pass Basic Auth headers in a JavaScript fetch request?

You must include an 'Authorization' header in your fetch options. The value should be formatted as 'Basic ' followed by the Base64-encoded string of your 'username:password'. Ensure there is a space between 'Basic' and the encoded string.

Are there alternative ways to automate API calls in Excel if Office Scripts fail?

If Office Scripts cannot bypass the CORS limitations, you can use Power Automate to handle the API integration in the cloud, or use local VBA macros/JS macros (in supporting suites like WPS Office) which operate outside of standard browser-based CORS restrictions.