【问题标题】:Microsoft graph api attachment error of unable to deserializeMicrosoft graph api 附件错误无法反序列化
【发布时间】:2021-04-23 20:31:41
【问题描述】:

我已经尝试过了,我可以创建事件,但是我得到了这个错误。

body_json={
        "@odata.type": "#microsoft.graph.fileAttachment",
        "name": "menu.txt",
        "contentBytes": "base64bWFjIGFuZCBjaGVlc2UgdG9kYXk="
    }



   API =" https://graph.microsoft.com/v1.0/users/{}/events/{}/attachments".format(userId,meetingID)
        body_json = json.dumps(body_json) 
        response = requests.request("POST", url=API, data=body_json, headers=self.headers)

错误:<Response [400]> {"error":{"code":"UnableToDeserializePostBody","message":"were unable to deserialize "}}

【问题讨论】:

    标签: microsoft-graph-api microsoft-graph-mail microsoft-graph-calendar


    【解决方案1】:

    这里的问题是因为您放入contentBytes 属性的数据不是BASE64。当您关注documentation 时,他们给出了该示例以使您了解数据是base64。但实际上在示例中它不是base64。所以你可以如下在线转换成base64并进行测试。

    这是我使用的请求正文,其中包含Hello World

    {
        "@odata.type": "#microsoft.graph.fileAttachment",
        "name": "menu.txt",
        "contentBytes": "SGVsbG8gV29ybGQ="
    }
    

    这在graph explorer 中给了我成功的结果。您可以使用它来测试 Graph API 调用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多