Skip to content

Cognitive Services authentication issue with CallAutomation_MCS_Sample #201

@dfoelker123

Description

@dfoelker123

Hello.

I am playing around with the CallAutomation_MCS_Sample and I am able to get most things working. The call to the ACS number is answered and I can see in the debug logging that integration with my Copilot Studio Agent is happening. However, there is no audio played back, and I receive this error:

Event received: {"ReasonCode":{},"FailedPlaySourceIndex":0,"CallConnectionId":"XXXXX","ServerCallId":"XXXXX","CorrelationId":"XXXXX","OperationContext":"Testing","ResultInformation":{"Code":401,"SubCode":8565,"Message":"Action failed due to a Cognitive Services authentication error. Please check your authorization input and ensure it is correct."}}

I did add this code to pull the Cognitive Services API key from appsettings.json and set it in the header:

//Get the Cognitive Services endpoint from appsettings.json
var cognitiveServicesEndpoint = builder.Configuration.GetValue("CognitiveServiceEndpoint");
ArgumentNullException.ThrowIfNullOrEmpty(cognitiveServicesEndpoint);

// Retrieve Cognitive Services API key from appsettings.json
var cognitiveServicesKey = builder.Configuration.GetValue("CognitiveServiceKey");
ArgumentNullException.ThrowIfNullOrEmpty(cognitiveServicesKey);

// Create an HTTP client for Cognitive Services
HttpClient cognitiveServicesClient = new HttpClient
{
BaseAddress = new Uri(cognitiveServicesEndpoint) // Set the base address
};
// Add the the Key for the Authentination Header
cognitiveServicesClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", cognitiveServicesKey);

But that did not make a difference. Is there something else that I am missing?

Pinging @ypradhan-msft for input.

Files:

appsettings.json

Program1.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions