Office Graph API - 从列表中获取项目

时间:2016-02-17 19:19:33

标签: sharepoint office365

Office Graph API中是否有办法访问特定列表中的项目 - 而不仅仅是我可以看到的项目,而是我可能无法访问的项目?

4 个答案:

答案 0 :(得分:1)

Microsoft Graph对SharePoint对象的访问目前属于Graph的测试版。请参阅https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/sharepoint

要访问特定项目,端点模式将是:     获取https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}/items/ {item-id}

例如:https:// graph.microsoft.com/beta/sites/mytenant.sharepoint.com:/sites/mysite:/Lists/Announcements/Items/1

至于能够访问您无权访问的项目:否。如果您可以使用任何API访问此类项目,那将是一个可怕的安全问题。

答案 1 :(得分:0)

在Microsoft Azure平台上注册的应用程序有两种权限。

一个是授权。在此方案中,用户委派对客户端应用程序的访问权限。我们可以调用REST API来获取登录者拥有的数据。

另一个是应用程序级别。在这种情况下,允许Web服务(机密客户端)在调用其他Web服务时使用其自己的凭据进行身份验证,而不是模拟用户。例如,如果服务或守护程序应用程序在Azure管理门户中选择了“读取所有用户的完整配置文件”权限,则它可以检索租户中的所有用户。我们可以通过以下API获取特定用户的驱动器:

GET /users/<id | userPrincipalName>/drive

有关用于处理OneDrive企业文件的REST API的更多详细信息,请参阅以下链接:

https://graph.microsoft.io/en-us/docs/api-reference/v1.0/resources/drive

以下是Azure AD支持的身份验证协议的链接:

https://msdn.microsoft.com/en-us/library/azure/dn151124.aspx

答案 2 :(得分:0)

不,您无法使用Graph API检索SharePoint列表项,但您可以使用 SharePoint REST API 。它与Graph API类似,支持OAuth。

在此处查看SharePoint API文档:https://msdn.microsoft.com/en-us/library/office/dn531433.aspx

答案 3 :(得分:0)

要从SharePoint中的列表中获取项目,可以使用SharePoint Rest API。使用rest api获取项目的示例代码如下:

// For SharePoint 2010
var strRestUrl = _spPageContextInfo.webServerRelativeUrl + "/_vti_bin/listdata.svc/{{listname}}

// For Office 365 or SharePoint 203
var strRestUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle({{listname}})/Items

$.ajax({
    url: strRestUrl,
    method: 'GET',
    headers: { "Accept": "application/json; odata=verbose" },
    success: function(response){
        // success callback function
    },
    complete: function(){
        // complete callback function
    },
    error: function (data) {
        // error callback function
        console.log(data.responseJSON.error);
    }
});

如果您使用的是SharePoint 2010,则Rest URL会有所不同,如果您使用的是SharePoint 2013 / Office 365,则其他URL也不同。希望这段代码可以帮到你。

有关REST API的更多详细信息,请参见以下链接: https://msdn.microsoft.com/en-us/library/office/dn531433.aspx

相关问题