1
votes

The bot is getting an error "Value cannot be null. Parameter name: clientId"
while executing GetConversationMembersWithHttpMessagesAsync method to get conversation users data. The conversation is just works fine, i can send and receive messages, but when i try to get info about the current conversation i get this exception.

Is there a necessity to create Bot Channels Registration at Azure to maintain such operations?

I've tried to manually add CustomHeaders with bearer token to http-query without a result.

customHeaders.Add("Authorization", new List<string> { "Bearer " + Global.accessToken });
membersListResponse = await connector.Conversations.GetConversationMembersWithHttpMessagesAsync(convId, customHeaders);

Error and stack trace:

Value cannot be null. Parameter name: clientId at Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential..ctor(String clientId, String clientSecret) at Microsoft.Bot.Connector.Authentication.MicrosoftAppCredentials.<>c__DisplayClass8_0.<.ctor>b__0() at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy1.CreateValue() at Microsoft.Bot.Connector.Authentication.MicrosoftAppCredentials.GetTokenAsync(Boolean forceRefresh) at Microsoft.Bot.Connector.Authentication.MicrosoftAppCredentials.ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken) at Microsoft.Bot.Connector.Conversations.GetConversationMembersWithHttpMessagesAsync(String conversationId, Dictionary2 customHeaders, CancellationToken cancellationToken)

1
Were you able to authenticate the user?Geethu Suresh
@GeethuSuresh I'm using MSappId and MSappPassword to sign in Bot Framework and they are applied correctly. The bot is available for communication and prompting for command execution, but that's it.Dee Wild

1 Answers

2
votes

The cause of this exception was an absense of auth data in the ConnectorClient used to post async request.

I've instantiated new MicrosoftAppCredentials class, passed appId and appPassword into it and then applied new instance to ConnectorClient. It was: var connector = new ConnectorClient(new Uri(context.Activity.ServiceUrl))

It became: var connector = new ConnectorClient(new Uri(context.Activity.ServiceUrl), BotCredentials.msAppCredentials);