Graph API在Power Automate的HTTP元素中返回空响应。

huangapple go评论70阅读模式
英文:

Graph API gives empty response in Power Automate HTTP element

问题

我正在尝试获取 SharePoint 网站的驱动器 ID。为了做到这一点,我使用以下元素:

Graph API在Power Automate的HTTP元素中返回空响应。

URI 的形式如下:

https://graph.microsoft.com/v1.0/sites/xxxx.sharepoint.com:xxxx.sharepoint.com,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/drives

结果是这样的(状态码 200):

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
    "value": []
}

当我在 Graph Explorer 中尝试完全相同的 URI 时,我得到了这个结果:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
    "value": [
        {
            "createdDateTime": "2022-10-16T00:17:42Z",
            "description": "",
            "id": "b!xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "lastModifiedDateTime": "2023-01-04T05:44:57Z",
            "name": "Documents",
            "webUrl": "https://xxxx.sharepoint.com/sites/xxxxxxxx/Shared%20Documents",
            "driveType": "documentLibrary",
            "createdBy": {
                "user": {
                    "displayName": "System Account"
                }
            },
            "lastModifiedBy": {
                "user": {
                    "email": "x.x@xxxx.xxx",
                    "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx",
                    "displayName": "x x"
                }
            },
            "owner": {
                "group": {
                    "email": "xxxxxxxx@xxxx.onmicrosoft.com",
                    "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx",
                    "displayName": "xxxxxxxx xxxx xxxx"
                }
            },
            "quota": {
                "deleted": 1794912,
                "remaining": 27487786218381,
                "state": "normal",
                "total": 27487790694400,
                "used": 2681107
            }
        }
    ]
}

这两个应用程序都具有以下权限:

  • Files.ReadWrite.All
  • Sites.ReadWrite.All

有人能告诉我为什么这两个应用程序的结果不同吗?任何帮助将不胜感激。

英文:

I am trying to get the drive-ids of a SharePoint site. In order to do that I use the following element:

Graph API在Power Automate的HTTP元素中返回空响应。

The URI is in the form of:

https://graph.microsoft.com/v1.0/sites/xxxx.sharepoint.com:xxxx.sharepoint.com,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/drives

The result is this (status code 200):

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
    "value": []
}

When I try exactly the same URI in Graph Explorer, I get this:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
    "value": [
        {
            "createdDateTime": "2022-10-16T00:17:42Z",
            "description": "",
            "id": "b!xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
            "lastModifiedDateTime": "2023-01-04T05:44:57Z",
            "name": "Documents",
            "webUrl": "https://xxxx.sharepoint.com/sites/xxxxxxxx/Shared%20Documents",
            "driveType": "documentLibrary",
            "createdBy": {
                "user": {
                    "displayName": "System Account"
                }
            },
            "lastModifiedBy": {
                "user": {
                    "email": "x.x@xxxx.xxx",
                    "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx",
                    "displayName": "x x"
	                }
            },
            "owner": {
                "group": {
                    "email": "xxxxxxxx@xxxx.onmicrosoft.com",
                    "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx",
                    "displayName": "xxxxxxxx xxxx xxxx"
                }
            },
            "quota": {
                "deleted": 1794912,
                "remaining": 27487786218381,
                "state": "normal",
                "total": 27487790694400,
                "used": 2681107
            }
        }
    ]
}

Both applications have the following permissions:

  • Files.ReadWrite.All
  • Sites.ReadWrite.All

Can anyone tell me why I am getting different results in the two applications? Any help would be greatly appreciated.

答案1

得分: 1

感谢 @jleture,我再次查看了我的权限,结果发现我使用的是委派权限,而不是应用程序权限。更改后问题得以解决。

英文:

Thanks to @jleture I had another look at my permissions and it turned out I was using delegated permissions instead of application permissions. Changing that solved the problem.

答案2

得分: 0

The URI must be:
https://graph.microsoft.com/v1.0/sites/xxxx.sharepoint.com,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/drives

(with comma)

But your screenshot shows something different, with a colon, like:
https://graph.microsoft.com/v1.0/sites/xxxx.sharepoint.com:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/drives

I try with my environment, and it's working fine:

Graph API在Power Automate的HTTP元素中返回空响应。

英文:

The URI must be:
https://graph.microsoft.com/v1.0/sites/xxxx.sharepoint.com,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx,xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/drives

(with coma)

But your screenshot shows something different, with colon, like:
https://graph.microsoft.com/v1.0/sites/xxxx.sharepoint.com:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/drives

I try with my environment and it's working fine:

Graph API在Power Automate的HTTP元素中返回空响应。

huangapple
  • 本文由 发表于 2023年6月8日 13:29:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76428853.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定