使用 Microsoft Graph 将图像发布到列表共享点 [英] Post image into list sharepoint with Microsoft Graph

查看:50
本文介绍了使用 Microsoft Graph 将图像发布到列表共享点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am working on MS Sharepoint with Microsoft Graph API. I call MS Graph API with .Net Core v2.1.

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

I want to do a POST request on a Sharepoint List where one of the column is an image column, but I can't find documentations about how to do that... Does anyone know more about how to do it please?

更新:

我看到了这个帖子 我改变了我的 json :

I saw this post and I changed my json :

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

但是我有这个错误信息:

But I have this error message :

{
    "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 而不是对象...

It seems that it expects the Photo's value to be a PrimitiveValue and not an object...

推荐答案

也许这应该对您有所帮助.

May be this should help you.

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

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

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

Assuming all your images are already uploaded in your site assets folder. Added the below JSON for the image column with site asset image URL id

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

希望能帮到你

这篇关于使用 Microsoft Graph 将图像发布到列表共享点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆