我尝试向Bot Connector服务发送消息。首先,我已成功登录MSA / AAD v2服务并检索令牌。
例如,我收到了:{"token_type":"Bearer","expires_in":3599,"ext_expires_in":0,"access_token":"eyJ0eXAi...}
所以我的下一步是将此令牌发送到Bot Connector服务,我尝试发送消息使用下一个URL和标题
POST /v3/conversations/12345/activities/67890
Authorization: Bearer eyJ0eXAi...
但是,我收到了下一个回复
{"code":"InvalidContent","message":"Invalid JSON: Unexpected token \n in JSON at position 77"}
状态代码为400。
我的代码示例
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
if err != nil {
fmt.Println(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", token)
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
我做错了什么?