首页 文章

Microrsoft Graph查询在API上返回空值

提问于
浏览
0

我正在使用python脚本来备份用户office 365 onedrive上的文件 . 我使用Graph API从用户onedrive获取对象列表 . 我从用户的根驱动器获取所有子对象的查询返回Graph Explorer中的预期值 . 在python脚本中使用相同的查询时,Graph返回一个空值 . 脚本中的其他查询返回正确的值 .

返回正确值的查询示例:https://graph.microsoft.com/v1.0/users/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx/drives脚本从返回值中提取drive-id以获取下一个查询中的子对象列表:https://graph.microsoft.com/v1.0/users('xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx')/ drives('xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx')/ root / children

从API调用返回空值,但从Graph explorer返回正确的值 .

有什么建议?

1 回答

  • 0

    您需要为graphScopes变量添加适当的权限

    我试图使用javascript代码获取一个驱动器文件的列表然后我使用此配置

    var applicationConfig = {
    clientID: "ea5*****-c721-4f13-a***-369f8c******",
    graphScopes: ["user.read"],
    graphEndpoint: "https://graph.microsoft.com/v1.0/me",
    webApi : "https://graph.microsoft.com/v1.0/me/drive/root/children"
    };
    

    它给出了空列表,但后来我在配置中更改了graphScopes

    var applicationConfig = {
    clientID: "ea5*****-c721-4f13-a***-369f8c******",
    graphScopes: ["Files.Read.All","Sites.Read.All"],
    graphEndpoint: "https://graph.microsoft.com/v1.0/me",
    webApi : "https://graph.microsoft.com/v1.0/me/drive/root/children"
    };
    

    然后它给了我在GraphExplorer中给出的列表

相关问题