Search code examples
botframeworkdirect-line-botframework

Invalid or missing activities in HTTP body - error as a response to


We are trying to connect Unity app with Chatbot using https://github.com/tompaana/bot-direct-line-for-unity. Starting a new conversation with bot is working properly, but when I try to send a message to it, instead of getting a response I end up with error attached below. Bot is working properly with web/skype, only problem we have is our unity implementation.

I wonder what we are missing in the POST in order to receive a proper response from bot.

Because Unity is somewhat missing features like Network/XHR from browsers developer toolkit, we used Fiddler to get those results:

here is POST sent to chatbot:

POST https://directline.botframework.com/v3/directline/conversations/CRar7Qz6VaEmIeMR6UmUC/activities HTTP/1.1
Host: directline.botframework.com
User-Agent: UnityPlayer/2017.3.1f1 (UnityWebRequest/1.0, libcurl/7.51.0-DEV)
Accept: */*
Accept-Encoding: identity
Transfer-Encoding: chunked
Authorization: Bearer XXX.edited_out.XXX
Content-Type: application/json
X-Unity-Version: 2017.3.1f1

76
{ "type": "message", "channelId": "directline", "from": { "id": "default-user", "name": "User" }, "text": "message text" }
0

here is the response:

HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 116
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/10.0
Request-Context: appId=cid-v1:91e46abb-4ce5-4d98-9375-02378f649011
X-Powered-By: ASP.NET
Strict-Transport-Security: max-age=31536000
Date: Tue, 15 May 2018 10:21:11 GMT

{
  "error": {
    "code": "MissingProperty",
    "message": "Invalid or missing activities in HTTP body"
  }
}

I'd like to know what we are missing in this POST.


Solution

  • In older version API, the default value of UnityWebRequest.chunkedTransfer property is true, as you mentioned, to prevent it, we can explicitly set:

    UnityWebRequest.chunkedTransfer = false;
    

    Besides, in the latest version, the default value of UnityWebRequest.chunkedTransfer property is false. So if upgrade and use the latest version, it might not cause this issue.

    enter image description here