在發送道活動機器人作爲每文檔這裏步驟,directline V3給出錯誤400
https://docs.botframework.com/en-us/restapi/directline3/#navtitle
我應該通過此作爲POST請求的主體內容
{
"type": "message",
"from": {
"id": "user1"
},
"text": "hello"
}
我正在使用以下參數在python中發出POST請求,但它不起作用。
msg = {"type": "message","channelId": "directline","conversation":{"id": str(convId)},"from":{"id": "test_user1"},"text": "hello"}
header = {"Authorization":"Bearer q1-Tr4sRrAI.cwA.BmE.n7xMxGl-QLoT7qvJ-tNIcwAd69V-KOn5see6ki5tmOM", "Content-Type":"application/json", "Content-Length": "512"}
send2 = "https://directline.botframework.com/v3/directline/conversations/"+str(convId)+"/activities"
rsa1 = requests.post(send2,data=msg, headers=header)
這給了我這個錯誤:
{
"error": {
"code": "MissingProperty",
"message": "Invalid or missing activities in HTTP body"
}
}
之前這一步一切工作正常。
編輯1:連我加入作爲更新代碼內容長度,它提供相同的錯誤
編輯2:如果我改變了MSG到json.dumps(MSG)
rsa1 = requests.post(send2,data=json.dumps(msg), headers=header)
我得到的迴應是:
{u'error': {u'message': u'Failed to send activity: bot returned an error', u'code': u'ServiceError'}}
{
"error": {
"code": "ServiceError",
"message": "Failed to send activity: bot returned an error"
}
}
直線API不工作,在Skype客戶端上一切工作正常。
可能的重複[MissingProperty錯誤在Microsoft Bot框架請求](https://stackoverflow.com/questions/41727907/missingproperty-error-in-microsoft-bot-framework-request) –
不,我已添加內容 - 但它也不起作用。 –