MS Teams Graph API使用JSON BATCH请求在通道中发布消息

问题描述 投票:0回答:1

我正在尝试使用JSON批处理在一个HTTP调用中组合多个请求,以使用GRAPH Explorer在MS Teams频道中发布消息。

url=https://graph.microsoft.com/beta/$batch
Request Body ={
"requests": [
  {
    "id": "1",
      "url": "/teams/cf82621f-bbe1-4bf1-a973-030fc6e58f03/channels/19:[email protected]/messages",
    "method": "POST",

    "body": {
  "content": "HelloWorld"
},"headers": {
      "Content-Type": "application/json"
    }

  }

]
}

发布后,我获得成功-状态码200,但响应为

{
    "responses": [
        {
            "id": "1",
            "status": 400,
            "body": {
                "error": {
                    "code": "BadRequest",
                    "message": "Value cannot be null.\r\nParameter name: Content",
                    "innerError": {
                        "request-id": "e23a0012-f40b-45e8-bae8-d68204217921",
                        "date": "2019-12-04T13:23:16"
                    }
                }
            }
        }
    ]
}

我在正文中提到了内容的价值,没有JSON批处理,对我来说很好用。

json rest microsoft-graph microsoft-teams microsoft-graph-teams
1个回答
0
投票

您可以尝试以下给出的Json吗?您需要发送两个正文属性,一个为批处理请求,另一个为团队端点的实际有效载荷。

"requests": [
  {
    "id": "1",
    "url": "/teams/cf82621f-bbe1-4bf1-a973-030fc6e58f03/channels/19:[email protected]/messages",
    "method": "POST",
    "body": {
      "body": {
        "content": "Hello World"
      }
    },
    "headers": {
      "Content-Type": "application/json"
    }
  }
]
}
© www.soinside.com 2019 - 2024. All rights reserved.