【问题标题】:MS Teams Graph API using JSON BATCH request to post message in channelMS Teams Graph API 使用 JSON BATCH 请求在频道中发布消息
【发布时间】:2019-12-04 13:50:35
【问题描述】:

我正在尝试使用 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:832f5e8d49ad4bfe96944d47cdd921d2@thread.skype/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-api microsoft-teams microsoft-graph-teams


    【解决方案1】:

    你可以试试下面给出的 Json 吗?您需要发送两个 body 属性,一个是 Batch 请求,一个是用于团队端点的实际负载。

    "requests": [
      {
        "id": "1",
        "url": "/teams/cf82621f-bbe1-4bf1-a973-030fc6e58f03/channels/19:832f5e8d49ad4bfe96944d47cdd921d2@thread.skype/messages",
        "method": "POST",
        "body": {
          "body": {
            "content": "Hello World"
          }
        },
        "headers": {
          "Content-Type": "application/json"
        }
      }
    ]
    }
    

    【讨论】:

    • 太棒了!!它奏效了我正在努力@Vikrant Singh
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-10
    • 2021-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-22
    相关资源
    最近更新 更多