调用 CreateDirectConversationAsync 时不允许获取错误 405 方法
Getting error 405 method not allowed when calling CreateDirectConversationAsync
任何调用方法的尝试
Task<ConversationResourceResponse> ConnectorClient.Conversations.CreateConversationAsync(ConversationParameters)
Task<ConversationResourceResponse> ConnectorClient.Conversations.CreateDirectConversationAsync(ChannelAccount, ChannelAccount)
针对端点:http://email.botframework.com/
因 HTTP 失败 405 方法而失败。
代码片段
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);
我找不到任何指示确切电子邮件通道端点的文档,因此我使用了端点 here,看起来像是用于 Skype 的,并将 skype
替换为 email
.我注意到关于不依赖 serviceUrl 稳定的警告,但如果我尝试在没有任何传入消息的情况下开始新对话,我不确定该选择什么。如果这是问题所在。
您必须添加受信任的服务 url :
MicrosoftAppCredentials.TrustServiceUrl(serviceUrl);
在那之后,你的构造函数应该是:
var connector = new ConnectorClient(new Uri(serviceUrl), microsoftAppId: appdId, microsoftAppPassword: appPassword);
任何调用方法的尝试
Task<ConversationResourceResponse> ConnectorClient.Conversations.CreateConversationAsync(ConversationParameters)
Task<ConversationResourceResponse> ConnectorClient.Conversations.CreateDirectConversationAsync(ChannelAccount, ChannelAccount)
针对端点:http://email.botframework.com/
因 HTTP 失败 405 方法而失败。
代码片段
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);
我找不到任何指示确切电子邮件通道端点的文档,因此我使用了端点 here,看起来像是用于 Skype 的,并将 skype
替换为 email
.我注意到关于不依赖 serviceUrl 稳定的警告,但如果我尝试在没有任何传入消息的情况下开始新对话,我不确定该选择什么。如果这是问题所在。
您必须添加受信任的服务 url :
MicrosoftAppCredentials.TrustServiceUrl(serviceUrl);
在那之后,你的构造函数应该是:
var connector = new ConnectorClient(new Uri(serviceUrl), microsoftAppId: appdId, microsoftAppPassword: appPassword);