The issue likely stems from how Visual Studio runs the application in a different runtime environment compared to PowerShell or a direct EXE execution. While the credentials and identity are the same, Visual Studio may not propagate Windows authentication tokens correctly or might introduce differences in TLS settings or request headers. This can lead to a 500 Internal Server Error from the Azure DevOps Server REST API. Running the app directly outside Visual Studio, setting SecurityProtocol
to TLS 1.2, and comparing network requests using Fiddler can help identify the root cause.