Forum Discussion

maheshkumargunasekaran's avatar
maheshkumargunasekaran
Copper Contributor
Sep 07, 2021

Getting Invalid status code 'TooManyRequests' while sending adaptive cards

Hi,

 

Am trying to send adaptive cards to multiple users through MS Teams with the help of C# application.

While sending cards to multiple users at the same time, am getting the error "Operation returned an invalid status code 'TooManyRequests'" as am using "Parallel.For" loop and await methods.

 

Am calling SendCard method multiple times. As it dont have any dependency, i have used Parallel thread and async/await methods.

 

Parallel.For(0, dataCount, new ParallelOptions { MaxDegreeOfParallelism = 38 }, async i =>
{
await SendCard(response, cloudTable, entities[i].PartitionKey, entities[i].RowKey, entities[i].ConversationId, entities[i].ServiceUrl, stringData, entities[i].MailId);
});

 

await connectorClient.Conversations.SendToConversationAsync(conversationId, (Activity)response);

 

Kindly help me on this.

1 Reply

Resources