简体   繁体   中英

Getting error 405 method not allowed when calling CreateDirectConversationAsync

Any attempt to call the methods

Task<ConversationResourceResponse> ConnectorClient.Conversations.CreateConversationAsync(ConversationParameters)
Task<ConversationResourceResponse> ConnectorClient.Conversations.CreateDirectConversationAsync(ChannelAccount, ChannelAccount)

Against endpoint: http://email.botframework.com/

fails with HTTP failure 405 method not allowed.

Code snippet

const string emailServiceUrl = "http://email.botframework.com/";
ConnectorClient connector = new ConnectorClient(new Uri(emailServiceUrl));

ChannelAccount botAccount = new ChannelAccount("bot@mail", null);
ChannelAccount userAccount = new ChannelAccount("user@mail", null);

var conversationId = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount);

I could not find any documentation that indicated the exact email channel endpoint, so I used the endpoint here , that looked like it was for skype, and replaced skype with email . I noticed the caveat about not relying on the serviceUrl being stable, but I'm not sure what to pick if I'm trying to start a new conversation without any incoming message. If that is the problem.

You must add trusted service url :

MicrosoftAppCredentials.TrustServiceUrl(serviceUrl);

After that, your constructor should be :

 var connector = new ConnectorClient(new Uri(serviceUrl), microsoftAppId: appdId, microsoftAppPassword: appPassword);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM