csharp-teams-sample-graph icon indicating copy to clipboard operation
csharp-teams-sample-graph copied to clipboard

Bad Request exception in CreateConversationAsync() method

Open Rashree138 opened this issue 6 years ago • 1 comments

HI Team,

I am trying to send a proactive message to user but getting error in last line, CreateConversationAsync() method. It throws Microsoft.Bot.Connector.ErrorResponseException

Code Sample :

string appId = ConfigurationManager.AppSettings["MicrosoftAppId"]; string appPassword = ConfigurationManager.AppSettings["MicrosoftAppPassword"]; var appCredentials = new MicrosoftAppCredentials(appId, appPassword); var connector = new ConnectorClient(new Uri(serviceUrl), appCredentials); MicrosoftAppCredentials.TrustServiceUrl(serviceUrl, DateTime.MaxValue); IMessageActivity message2 = Activity.CreateMessageActivity(); message2.Type = ActivityTypes.Message; message2.Text = "Testing group proactive message"; List accounts = new List() { new ChannelAccount("userid", "Username") }; ConversationParameters parameters = new ConversationParameters(false, botAccount, accounts, "Testing Proactive", (Activity)message2, null); await connector.Conversations.CreateConversationAsync(parameters);

Output:

An error has occurred. Operation returned an invalid status code 'BadRequest' ExceptionType - Microsoft.Bot.Connector.ErrorResponseException StackTrace - at Microsoft.Bot.Connector.Conversations.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Bot.Connector.ConversationsExtensions.d__1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Indigo_ProactiveMessages.ConversationStarter.d__7.MoveNext() in C:\Users\documents\visual studio 2015\Projects\ProactiveMessages\ProactiveMessages\ConversationStarter.cs:line 102 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at Indigo_ProactiveMessages.CustomWebAPIController.d__0.MoveNext() in C:\Users\documents\visual studio 2015\Projects\ProactiveMessages\ProactiveMessages\Controllers\CustomWebAPIController.cs:line 25

Rashree138 avatar Mar 05 '20 18:03 Rashree138

Closing this as we are closing this repository and will no longer maintain it. The Teams code snippets in this sample are replicated in the ASP.NET Core Graph Snippets sample. We apologize for any inconvenience.

jasonjoh avatar Jun 22 '20 18:06 jasonjoh