Microsoft Graph 未为文件创建嵌入 link

Microsoft graph not creating embed link for file

向 Microsoft Graph 发送请求时:

POST 'https://graph.microsoft.com/v1.0/me/drive/root:/017_2018-08-12_18.47.27.jpg:/createLink'
content-type': 'application/json
{
  "type": "embed"
}

我只得到

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#permission",
  "@odata.type": "#microsoft.graph.permission",
  "id": "5o98ENjWYH2pNK8wO5_d7QHUrdk",
  "roles": ["read"],
  "shareId": "s!AgDP2w-bgvZL****evpaN2yel",
  "link": {
    "type": "embed",
    "webUrl": "https://onedrive.live.com/embed?resid=4B****U"

但根据 documentation,我还应该使用 Iframe link 获取 WebHtml,而不仅仅是 webUrl,这就是我正在寻找的,因此我可以为照片生成 links , 并将它们放在网站上。

我是不是做错了什么或者有什么办法可以让我获得相同的嵌入 url 我可以通过手动点击 onedrive 生成​​?

我正在使用个人 one drive 帐户。

在 graph explorer 上尝试这个对我来说在 v1.0 端点上不起作用。但是,使用 beta 端点确实 return webHtml 属性 如下所示

基本上您需要做的是将 url 中的 v1.0 段更改为 beta

POST 'https://graph.microsoft.com/beta/me/drive/root:/017_2018-08-12_18.47.27.jpg:/createLink'
content-type': 'application/json
{
  "type": "embed"
}

你应该找回这样的东西

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#permission",
    "@odata.type": "#microsoft.graph.permission",
    "id": "p6z1ZAtRqKFwqHNVfaa6mPFQIyI",
    "roles": [
        "read"
    ],
    "shareId": "s!AorKRTkoJljsixZbAANWreQhS7gk",
    "expirationDateTime": "0001-01-01T00:00:00Z",
    "hasPassword": false,
    "link": {
        "type": "embed",
        "webUrl": "https://onedrive.live.com/embed?resid=EC5826283945CA8A%211430&authkey=!AFsAA1at5CFLuCQ",
        "webHtml": "<iframe src=\"https://onedrive.live.com/embed?resid=EC5826283945CA8A%211430&authkey=!AFsAA1at5CFLuCQ\" width=\"98\" height=\"120\" frameborder=\"0\" scrolling=\"no\"></iframe>"
    }
}