Die REST-API gibt das JSON-Format des POST-Nachrichtentexts beim Senden einer Nachricht an, es ist jedoch nicht klar, was in die Felder gehört. Hier ist das Format ...POST-Nachricht zum Senden einer neuen Nachricht mit dem Microsoft BotConnector
{
"id": "string", // ?
"conversationId": "string", // Conversation ID
"created": "2016-06-22T10:45:48.618Z", // Current time?
"from": "string", // Username?
"text": "string", // The message to be sent
"channelData": "string", // ?
"images": [
"string" // Image URL?
],
"attachments": [
{
"url": "string", // Attachment URL
"contentType": "string" // ContentType
}
],
"eTag": "string" // ?
}
Ich habe das Feld markiert, dass ich unsicher bin. Im Moment sende ich die Anfragen und bekomme einen 500 Server Fehler zurück. Der Bot funktioniert lokal gut mit dem lokalen Bot-Emulator.
Dieser JSON muss in einer Android-App erstellt werden.
EDIT: Hier ist der abgefangenen JSON und Antwort, die ich das Senden am
POST https://directline.botframework.com/api/conversations/D0I7X8284zv/messages HTTP/1.1
Host: directline.botframework.com
Connection: keep-alive
Content-Length: 239
Authorization: BotConnector Ve7jitnSIdE.dAA.RAAwAEkANwBYADgAMgA4ADQAegB2AA.Iy0ZhjLN0QE.e9o7v6n2Xz4.8C7zj2UlOP6202jMEpHqjXVfZxexO5JxzFE7VrRgaXg
Postman-Token: dd7b4c43-84ea-7c38-bd2c-681f6c031eb0
Cache-Control: no-cache
Origin: chrome-extension://aicmkgpgakddgnaphhhpliifpcfhicfo
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
Content-Type: application/json
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6,fr;q=0.4
Cookie: XXXXXXXXXXXXXXXXXXXXX
{
"id": "SomeId",
"conversationId": "D0I7X8284zv",
"created": "2016-06-23T09:05:06.718Z",
"from": "someusername",
"text": "annual leave",
"channelData": "Conv1",
"images": [],
"attachments": [],
"eTag": "blah"
}
HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 43
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
Set-Cookie: UserId=XXXXXXXXXXXXXXXXXXXXXXX; path=/
Access-Control-Allow-Origin: *
X-Powered-By: ASP.NET
Strict-Transport-Security: max-age=31536000
Date: Thu, 23 Jun 2016 09:06:06 GMT
{
"message": "failed to send message"
}
Verwenden Sie direkte API? – SilentCoder
Ja, ich benutze die Direct Line REST API – Brendan