Troubleshooting MS Copilot Studio HTTP Request Failures: A Practical Solution
The Problem Description
If you're working with MS Copilot Studio, you've likely encountered this frustrating error:
MS Copilot Studio --
An error has occurred. Error code: HttpRequestFailure Conversation Id: e3QGxxxxxx01NA-us Time (UTC): 2025-06-01T16:14:05.372Z.
This is a common issue that occurs frequently with MS Copilot Studio, though not consistently. Based on my experience, this isn't a code issue but rather a configuration issue related to the MS environment.
What We Discovered
When we enabled the Continue on Error feature in Copilot Studio, we encountered an HTTP 408 error (Request Timeout). This means the server didn't receive a complete request from the client within the expected timeframe.
After researching and contacting our support counterpart, they provided the following stacktrace:
CorrelationId: xxxx-b674-4c2a-xxxx-184197387367
Exception: Microsoft.IdentityModel.S2S.S2SAuthenticationException: S2xx2099:
An exception has been caught while validating the request.
Exception: [PII of type 'System.AggregateException' is hidden]
---> System.AggregateException: S2xx2096: Microsoft.IdentityModel.S2S.JwtAuthenticationHandler
caught exceptions when validating the token. See AuthenticationResult.InboundPolicyEvaluationResults
for additional details. (S2xx2086: An exception has been caught while validating the request
applying the policy with id : 'User'.
Exception: Microsoft.IdentityModel.Tokens.SecurityTokenInvalidAudienceException: IDXxx214:
Audience validation failed. Audiences: 'xxx-xxx-4af1-b9a8-09a648fb6699'.
Did not match: validationParameters.ValidAudience: 'null' or validationParameters.ValidAudiences:
Unfortunately, the issue remains unresolved as of when I write this post.
Our Temporary Solution: Retry Logic
As a quick fix, we implemented retry logic in the Copilot Studio workflow UI using the Goto Step feature for HTTP nodes, with a maximum retry count of 3.
Implementation Code
Here's the complete code snippet for our temporary fix:
1. Initialize Retry Counter
- kind: SetVariable
id: setVariable_btVmH4
displayName: retryCount
variable: Topic.retryCount
value: 0
2. HTTP Request with Error Handling
- kind: HttpRequestAction
id: JDNAtp
displayName: PF - HTTP Request
method: Post
url: https://pf-end-point-autoendpoint.eastus.inference.ml.azure.com/score
headers:
Authorization: Bearer 6mIiASFPiZKeaRxxUk4JQQJ99BGAAAAAAAAAAAAINFRAZML2PC6
azureml-model-deployment: auto-20250708-551705
Content-Type: application/json
body:
kind: JsonRequestContent
content: |
={
question:Topic.UserQuery,
chat_history:Global.VarHistory
}
errorHandling:
kind: ContinueOnErrorBehavior
statusCode: Topic.ErrorStatusCode
requestTimeoutInMilliseconds: 30000
response: Topic.KBAresponse
responseSchema: Any
responseHeaders: Topic.ResponseHeader
3. Error Status Logging
- kind: SendActivity
id: sendActivity_dxnBNR
activity: After HTTP request --- Error Code--- {Topic.ErrorStatusCode}
4. Retry Logic Implementation
- kind: ConditionGroup
id: conditionGroup_cN6dbL
conditions:
- id: conditionItem_xH0b5H
condition: =!IsBlank(Topic.ErrorStatusCode)
displayName: Condition to try Retry Logic
actions:
- kind: SetVariable
id: setVariable_9Lszte
variable: Topic.retryCount
value: =Topic.retryCount + 1
- kind: ConditionGroup
id: conditionGroup_UA3fsX
conditions:
- id: conditionItem_itQSEP
condition: =Topic.retryCount < 3
actions:
- kind: SendActivity
id: sendActivity_Y0iihp
activity: ---->{Topic.retryCount}---
- kind: GotoAction
id: S4S1LT
actionId: JDNAtp
- kind: SendActivity
id: sendActivity_vOX9b5
activity: Errorred --{Topic.retryCount}
How It Works
- Initialize a retry counter to 0
- Execute the HTTP request with error handling enabled
- Check if an error occurred (ErrorStatusCode is not blank)
- Increment the retry counter
- Retry up to 3 times using the GotoAction to jump back to the HTTP request
- Log the final error state if all retries fail
Key Takeaways
- This appears to be an authentication/token validation issue on Microsoft's end
- The Continue on Error feature is essential for implementing retry logic
- Retry logic provides a practical workaround while waiting for Microsoft to resolve the underlying issue
- The GotoAction feature in Copilot Studio makes implementing retry patterns straightforward
Conclusion
While this isn't a permanent solution, it significantly improves the reliability of HTTP requests in MS Copilot Studio workflows. If you're experiencing similar issues, consider implementing this retry pattern until Microsoft addresses the root cause.
Have you encountered similar issues with MS Copilot Studio? Share your experiences and solutions in the comments below!
Tags: #MSCopilotStudio #Azure #HTTPErrors #RetryLogic #Troubleshooting #Microsoft
How do you handle different types of HTTP errors (404, 500, etc.)?
ReplyDeleteyou can enable to the "Continue on Error", in CoPilot studio, for the HTTP Node.
DeletePlease see the screen shot
errorHandling:
kind: ContinueOnErrorBehavior
statusCode: Topic.ErrorStatusCode
Then i followed as below
Stored the error code using statusCode
Add a Condition node after the HTTP request to check Topic.ErrorStatusCode.
Use branches to act on specific status codes.