【问题标题】:Post image into list sharepoint with Microsoft Graph使用 Microsoft Graph 将图像发布到列表共享点
【发布时间】:2019-10-02 18:04:00
【问题描述】:

我正在使用 Microsoft Graph API 开发 MS Sharepoint。我用 .Net Core v2.1 调用 MS Graph API。

我想在其中一列是图像列的 Sharepoint 列表上执行 POST 请求,但我找不到有关如何执行此操作的文档...请问有人知道更多有关如何执行此操作的信息吗?

更新:

我看到了这个post,我改变了我的json:

{
  "fields": {
    "Title": "Test",
    "Photo": {
      "Url": "https://myurl/picture.jpg",
      "Description":"This is my picture"
    }
  }
}

但是我有这个错误信息:

{
    "error": {
        "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
        "message": "A value without a type name was found and no expected type is available. When the model is specified, each value in the payload must have a type which can be either specified in the payload, explicitly by the caller or implicitly inferred from the parent value.",
        "innerError": {
            "request-id": "34773f4f-131f-4249-8a03-b8a820ba4a6b",
            "date": "2019-05-16T13:26:17"
        }
    }
}

它似乎期望 Photo 的值是 PrimitiveValue 而不是对象...

【问题讨论】:

    标签: c# sharepoint microsoft-graph-api .net-core-2.1


    【解决方案1】:

    也许这应该对你有所帮助。

    发布 https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items

    假设您的所有图片都已上传到您的网站资产文件夹中。为带有站点资产图像 URL id 的图像列添加了以下 JSON

    POST https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items
    Content-Type: application/json
    
    {
      "fields": {
        "Title": "Widget",
        "Color": "Purple",
        "Weight": 32,
        "image": "/assets/image5.png" 
      }
    }
    

    参考:https://docs.microsoft.com/en-us/graph/api/listitem-create?view=graph-rest-1.0&tabs=javascript

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-07
      • 2023-03-22
      • 2017-03-25
      • 2022-06-29
      • 1970-01-01
      • 2021-04-07
      • 2018-12-12
      • 2011-12-07
      相关资源
      最近更新 更多