How to Fix Office Scripts Basic Authentication Fetch Request Fails
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.
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.
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.
Open your web browser and go to the official Microsoft Q&A website.
Search for and select the 'Office Development' tag, which connects you directly with developers and Microsoft specialists.
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.
Wait for a specialist to review your authentication headers and endpoint configuration to determine if a workaround is required for the Office Scripts environment.
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. Download WPS Office: Visit the official WPS website and download the free WPS Office suite for your operating system.
- 2. Open Your Spreadsheets: Launch WPS Spreadsheet and open your existing .xlsx files directly without losing any formatting or data.
- 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.

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.




