Operation returned an invalid status code 'Forbidden'/'NotFound'

Copper Contributor

I am having a recurring problem with our Bot in Teams that I am struggling to find a root cause and fix for.

 

We have a bot that has been developed using the C# Bot Framework SDK Version 4 and .NET Core 3.1 that is installed via Teams. There is an issue that is recurring in our Application Insights that I am struggling to figure out. There are multiple exceptions that happen intermittently with the message "Operation returned an invalid status code 'Forbidden'" or "Operation returned an invalid status code 'NotFound'". The only commonality with all these errors are that they happen in the same area of the code.

 

The bot we have implemented makes use of a waterfall dialog system to handle the authentication and login for users and handle incoming messages once authenticated. The errors always occur when the bot is trying to move on to the next dialog step after completing the OAuthPrompt step, as shown in the screenshot below.

amatthewsyakchat_0-1653492996917.png

 

I have searched to try and find why this is happening or even a solution to this issue and although I have found similar problems and have tried their solutions, they have not been able to fix this error.

 

Has anyone else had an issue similar to this, or know what the problem could be?

20 Replies
@amatthews-yakchat- Could please share the any referred sample or repro steps,So that we can tried it from our end?
@amatthews-yakchat-We are not able to reproduce the scenario.Could you please share the any referred sample or repro steps, So that we can investigate it from our end?

@Sayali-MSFT Apologies for the delayed response, I was on vacation for the last week. I'm not sure what the repro steps are for this issue as it happens intermittently and looking at the telemetry there doesn't seem to be any common ground or any cases where it happens 100% of the time.

 

I've included the area of code where I think the error originates from below. Like I mentioned in my original post, we are using the WaterfallDialog approach with this bot and this is one of the steps, the error seems to be thrown when moving away from this step to the next.

 

private async Task<DialogTurnResult> PromptStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
	try
	{
		UserProfile Profile = await this._stateAccessor.GetAsync(stepContext.Context, () => new UserProfile());

		if (String.IsNullOrWhiteSpace(stepContext.Context.Activity.Text))
		{
			if (!String.IsNullOrWhiteSpace(Profile.CachedMessage))
			{
				stepContext.Context.Activity.Text = Profile.CachedMessage;
				Profile.CachedMessage = String.Empty;
			}
		}

		return await stepContext.BeginDialogAsync(nameof(OAuthPrompt), null, cancellationToken);
	}
	catch (Exception exc)
	{
		Dictionary<String, String> Properties = new Dictionary<String, String>();
		Properties.Add("Class", "MainDialog");
		Properties.Add("Method", "PromptStepAsync");

		AppInsightsHelper.LogException(exc, Properties, stepContext.Context);

		await stepContext.Context.SendActivityAsync(BotResponse.ErrorMessage_GenericErrorResponse);
		return await stepContext.EndDialogAsync(cancellationToken: cancellationToken);
	}
}

 

@amatthews-yakchat -We are tried with the following sample. It works for us .Could you please check it once from your end some points?
1.have you added bot auth on your azure bot and url in same format correct ?
2.In App Setting check the connection name?
Sample Link-
https://github.com/microsoft/BotBuilder-Samples/tree/14ed6ea596aa84d2b561d00f58f828ae8cc1a89a/sample...
This is the sample we used as our starting point for creating our bot. The connection name in the App Settings is correct. I'm sorry but I don't understand what you mean by your first point? Where would I check for this bot auth url?

@amatthews-yakchat - On Azure Portal-  https://portal.azure.com/#home
You need to check the URL and Bot connection Name also.

I'm really sorry but I still don't understand what you need me to check, do you have an example of what I am looking for, or some sort of screenshot please?

@amatthews-yakchat -Could you please provide sample which you refer,so that I can guide you proper way?

I am trying to find what you are referring to when you said "have you added bot auth on your azure bot and url in same format" but I don't know where in the Azure Portal to check for this information. I can confirm the Connection Name in the App Settings is correct, but I cannot confirm this url. I have looked in the Azure Bot resource and the App Service and I cannot see anything about bot auth, I just need to know where I should be looking to find this information.

@amatthews-yakchat -You can check here Connection name and URL.
azure.png

@Sayali-MSFT I have noticed that we are using 'Azure Active Directory' as the Service Provider on our bot authentication, would updating this to use 'Azure Active Directory v2' help with the issues we are experiencing?

 

Screenshot 2022-06-15 101727.png

@Sayali-MSFT We are still struggling with this issue, but I have some more information that might be helpful. Here are 3 stack traces from our telemetry, the first two are the 'Operation Failed: NotFound' and 'Operation Failed: Forbidden' errors that are occurring in the OAuth prompt step of our bot.

 

The third is another similar error I managed to find from another area of our code, where we are displaying a proactive message from the bot to the user. Looking at the traces they seem to have similar root causes, with the error originally coming from Microsoft.Bot.Connector.Conversations+<ReplyToActivityWithHttpMessagesAsync>

 


'Operation Failed: Forbidden' Trace 1

 

Microsoft.Bot.Schema.ErrorResponseException:
at Microsoft.Bot.Connector.Conversations+<ReplyToActivityWithHttpMessagesAsync>d__10.MoveNext (Microsoft.Bot.Connector, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Connector.ConversationsExtensions+<ReplyToActivityAsync>d__17.MoveNext (Microsoft.Bot.Connector, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.BotFrameworkAdapter+<SendActivitiesAsync>d__34.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.TurnContext+<>c__DisplayClass30_0+<<SendActivitiesAsync>g__SendActivitiesThroughAdapter|1>d.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.TurnContext+<SendActivityAsync>d__29.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.TurnContext+<SendActivityAsync>d__28.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at YakBotService.Dialogs.MainDialog+<PromptStepAsync>d__8.MoveNext (YakBotService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Dev\YakBot_Old_New\Dialogs\MainDialog.cs:140)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog+<OnStepAsync>d__11.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog+<RunStepAsync>d__12.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog+<ResumeDialogAsync>d__9.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallStepContext+<NextAsync>d__18.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at YakBotService.Dialogs.MainDialog+<AdminConsentStepAsync>d__7.MoveNext (YakBotService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Dev\YakBot_Old_New\Dialogs\MainDialog.cs:108)



'Operation Failed: NotFound' Trace

 

Microsoft.Bot.Schema.ErrorResponseException:
at Microsoft.Bot.Connector.Conversations+<ReplyToActivityWithHttpMessagesAsync>d__10.MoveNext (Microsoft.Bot.Connector, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Connector.ConversationsExtensions+<ReplyToActivityAsync>d__17.MoveNext (Microsoft.Bot.Connector, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.BotFrameworkAdapter+<SendActivitiesAsync>d__34.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.TurnContext+<>c__DisplayClass30_0+<<SendActivitiesAsync>g__SendActivitiesThroughAdapter|1>d.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.TurnContext+<SendActivityAsync>d__29.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.TurnContext+<SendActivityAsync>d__28.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at YakBotService.Dialogs.MainDialog+<PromptStepAsync>d__8.MoveNext (YakBotService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Dev\YakBot_Old_New\Dialogs\MainDialog.cs:140)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog+<OnStepAsync>d__11.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog+<RunStepAsync>d__12.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog+<ResumeDialogAsync>d__9.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallStepContext+<NextAsync>d__18.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at YakBotService.Dialogs.MainDialog+<AdminConsentStepAsync>d__7.MoveNext (YakBotService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Dev\YakBot_Old_New\Dialogs\MainDialog.cs:108)



'Operation Failed: Forbidden' Trace 2

 

Microsoft.Bot.Schema.ErrorResponseException:
at Microsoft.Bot.Connector.Conversations+<ReplyToActivityWithHttpMessagesAsync>d__10.MoveNext (Microsoft.Bot.Connector, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Connector.ConversationsExtensions+<ReplyToActivityAsync>d__17.MoveNext (Microsoft.Bot.Connector, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.BotFrameworkAdapter+<SendActivitiesAsync>d__34.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.TurnContext+<>c__DisplayClass30_0+<<SendActivitiesAsync>g__SendActivitiesThroughAdapter|1>d.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.TurnContext+<SendActivityAsync>d__29.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.TurnContext+<SendActivityAsync>d__28.MoveNext (Microsoft.Bot.Builder, Version=4.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at YakBotService.Dialogs.MainDialog+<PromptStepAsync>d__8.MoveNext (YakBotService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Dev\YakBot_Old_New\Dialogs\MainDialog.cs:140)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog+<OnStepAsync>d__11.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog+<RunStepAsync>d__12.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog+<ResumeDialogAsync>d__9.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Bot.Builder.Dialogs.WaterfallStepContext+<NextAsync>d__18.MoveNext (Microsoft.Bot.Builder.Dialogs, Version=4.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at YakBotService.Dialogs.MainDialog+<AdminConsentStepAsync>d__7.MoveNext (YakBotService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Dev\YakBot_Old_New\Dialogs\MainDialog.cs:108)


Hopefully this new information is useful. We are still using the AAD V1 OAuth Service Provider for now, but we can update this if you think it will help solve this issue?

I was just wondering if this was still being looked into, were the stack traces I have provided any help with this issue?
@amatthews-yakchat - Have you tried with AAD V2 OAuth service?
Sorry for the late response, we have tried AAD V2 OAuth service and we still get the same issue.
I was just wondering if there was any more news on this ongoing issue?

According to the above error log, this error response occurs when it returns the invalid status code.
ErrorResponseException-Thrown when the operation returned an invalid status code.
Ref Doc-Conversations.ReplyToActivityWithHttpMessagesAsync Method (Microsoft.Bot.Connector) | Microsoft Docs

I understand that the error is because ReplyToActivityWithHttpMessagesAsync is returning an invalid code, but we do not call this method directly so I don't understand what we can do to solve this problem?