fix: add -UseBasicParsing to Stop-API Invoke-WebRequest#6
Open
Daymarvi wants to merge 1 commit into
Open
Conversation
Stop-API was failing on Windows Server without Internet Explorer: 'The response content cannot be parsed because the Internet Explorer engine is not available'. Added -UseBasicParsing parameter which has no dependency on IE COM objects and works under SYSTEM account.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
Stop-APIfunction failing on Windows Server when Internet Explorer is not available or not initialized (Server Core, SYSTEM account).Problem
When the WinBGP engine tries to stop the API via
Invoke-WebRequest, it fails because the cmdlet attempts to use the IE COM engine (mshtml.dll) for HTML parsing by default in PowerShell 5.1. This produces the following error:Error stopping API engine: The response content cannot be parsed because the Internet Explorer
engine is not available, or Internet Explorer's first-launch configuration is not complete.
Specify the UseBasicParsing parameter and try again.
This caused the API stop to silently fail, leaving the port blocked and requiring the Watchdog to restart the API (with port conflict errors in the logs).
Fix
Added
-UseBasicParsingto theInvoke-WebRequestcall inStop-API(). This parameter bypasses the IE dependency and works in all contexts (SYSTEM account, Server Core, PowerShell 5.1).Files changed
src/WinBGP-Engine.ps1(1 line changed)Test Results
Tested on local server:
WinBGP -RestartAPIInvoke-RestMethod http://127.0.0.1:8888/apiEvent Log evidence (after fix)
17/06/2026 09:55:32 Information API started - Listening on '127.0.0.1:8888' (Protocol: http)
17/06/2026 09:55:32 Information API started - Listening on 'ip:8888' (Protocol: https)
17/06/2026 09:55:27 Information Starting API engine
17/06/2026 09:55:27 Information Stopping API engine ← No IE error ✅
17/06/2026 09:55:27 Information Restarting API engine