Microsoft.Rest.HttpOperationException in Microsoft.Bot.Builder.dll ("Access Denied") when testing PromptDialog.Confirm

I am trying to check an IDialog stream with a fake message, therefore:

var toBot = new Message() { ConversationId = Guid.NewGuid().ToString(), Text = "Test", }; Func<IDialog<T>> MakeRoot = () => testDialog; toBot.From = new ChannelAccount(Guid.NewGuid().ToString()); toBot.To = new ChannelAccount(Guid.NewGuid().ToString()); 

When it gets into PromptDialog.Confirm, it throws a Microsoft.Rest.HttpOperationException exception in the Microsoft.Bot.Builder.dll exception (access exception).

If I do not create

  toBot.From = new ChannelAccount(Guid.NewGuid().ToString()); 

it throws a System.NullReferenceException for ChannelId.

PromptDialog.Confirm is as follows:

  PromptDialog.Confirm(context, AfterErrorConfirmationAsync, Strings.ConfirmError, Strings.InvalidInput); 

How can I get around this problem?

+5
source share
1 answer

The problem was caused by this:

  await context.PostAsync(replyMessage); PromptDialog.Confirm(context, AfterErrorConfirmationAsync, Strings.ConfirmError, Strings.InvalidInput); 

The presence of the confirmation dialog immediately after the publication of the message to the user caused an exception and subsequently tested the failure. However, he did not throw this exception at runtime.

I solved the problem above by combining the response message with the confirmation line as follows:

  PromptDialog.Confirm(context, AfterErrorProcessingAsync, replyMessage + "\n\n" + Strings.ConfirmError, Strings.InvalidInput); 

If you leave this question open, if anyone has a better workaround.

+2
source

All Articles