나는 MS 봇 프레임 워크를 2 주 동안 사용해 봤지만 훌륭하게 작동했지만 오늘은이 401 Unauthorized 오류가 발생했습니다.botframework 401 Unauthorized
MicrosoftAppId 및 MicrosoftAppPassword에 대한 빈 값을 설정하면 202 Accepted Code 및 JSON이 작동합니다.
{
"type": "message",
"timestamp": "2017-05-05T19:16:05.9383241Z",
"serviceUrl": "http://localhost:9000/",
"channelId": "emulator",
"from": {
"id": "56800324",
"name": "Bot1"
},
"conversation": {
"isGroup": false,
"id": "8a684db8",
"name": "Conv1"
},
"recipient": {
"id": "2c1c7fa3",
"name": "User1"
},
"text": "Has dicho: 55 tiene 2 caracteres. De momento no se hacer más.",
"attachments": [],
"entities": [],
"replyToId": "4e4621d62e544a99aa1ea385b12d536f"
}
내가 설정 MicrosoftAppId 및 MicrosoftAppPassword에 대한 값 (예, dev.botframework.com 그것을 몇 번을 확인 한 후 모두 맞다) 경우 작동하지 않습니다
401 Unathorized
Connection: Keep-Alive
Content-Length: 540
Content-type: application/json ; charset=utf-8
Host: Localhost:9000
User-Agent: Microsoft.Bot.Connector.ConnectorClient/3.5.3.0 Microsoft-BotFramework/3.1 (BotBuilder .Net/3.5.3.0)
및 JSON : 나는 dev.botframework.com에서 내 봇에 연결을 테스트하는 경우
{
"type": "message",
"timestamp": "2017-05-05T19:19:15.4091892Z",
"serviceUrl": "http://localhost:9000/",
"channelId": "emulator",
"from": {
"id": "56800324",
"name": "Bot1"
},
"conversation": {
"isGroup": false,
"id": "8a684db8",
"name": "Conv1"
},
"recipient": {
"id": "2c1c7fa3",
"name": "User1"
},
"text": "Has dicho: sdfs tiene 4 caracteres. De momento no se hacer más.",
"attachments": [],
"entities": [],
"replyToId": "0adec452277a489e9acc5b4403fa5965"
}
또한 무단 얻을.
아이디어가 있으십니까?
감사합니다.
UPDATE : 이 내 MessagesController 클래스입니다 :
namespace Geni.Controllers
{
[BotAuthentication]
public class MessagesController : ApiController
{
/// <summary>
/// POST: api/Messages
/// Receive a message from a user and reply to it
/// </summary>
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
// calculate something for us to return
int length = (activity.Text ?? string.Empty).Length;
// return our reply to the user
Activity reply = activity.CreateReply($"Has dicho: {activity.Text} tiene {length} caracteres. De momento no se hacer más.");
await connector.Conversations.ReplyToActivityAsync(reply);
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
private Activity HandleSystemMessage(Activity message)
{
if (message.Type == ActivityTypes.DeleteUserData)
{
// Implement user deletion here
// If we handle user deletion, return a real message
}
else if (message.Type == ActivityTypes.ConversationUpdate)
{
// Handle conversation state changes, like members being added and removed
// Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
// Not available in all channels
}
else if (message.Type == ActivityTypes.ContactRelationUpdate)
{
// Handle add/remove from contact lists
// Activity.From + Activity.Action represent what happened
}
else if (message.Type == ActivityTypes.Typing)
{
// Handle knowing tha the user is typing
}
else if (message.Type == ActivityTypes.Ping)
{
}
return null;
}
}
}
일부 값이 잘못되었거나 ... 봇에 뭔가가 누락되었습니다. 귀하의 컨트롤러에 코드를 게시하십시오 –