获取资源
本文内容
命名空间:microsoft.graph
检索文件或图像资源对象的二 进制 数据。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Notes.Read、Notes.ReadWrite、Notes.Read.All、Notes.ReadWrite.All
委派(个人 Microsoft 帐户)
Notes.Read、Notes.ReadWrite
应用程序
Notes.Read.All、Notes.ReadWrite.All
HTTP 请求
GET /me/onenote/resources/{id}/content
GET /users/{id | userPrincipalName}/onenote/resources/{id}/content
GET /groups/{id}/onenote/resources/{id}/content
GET /sites/{id}/onenote/resources/{id}/content
名称
类型
说明
Authorization
string
Bearer {token}。必需。
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法在响应正文中返回 响应代码和图像或 200 OK 文件二进制数据。
注意:图像不会直接在浏览器中呈现,因为它们需要授权才能检索它们,如页面内容的其余部分。
示例
请求
下面是一个请求示例。
GET https://graph.microsoft.com/v1.0/me/onenote/resources/{id}/content
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var stream = await graphClient.Me.Onenote.Resources["{onenoteResource-id}"].Content
.Request()
.GetAsync();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
let stream = await client.api('/me/onenote/resources/{id}/content')
.get();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/onenote/resources/{id}/content"]]];
[urlRequest setHTTPMethod:@"GET"];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
MSGraphStream *stream = [[MSGraphStream alloc] initWithData:data error:&nserror];
}];
[meDataTask execute];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
InputStream stream = graphClient.customRequest("/me/onenote/resources/{id}/content", InputStream.class)
.buildRequest()
.get();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
onenoteResourceId := "onenoteResource-id"
graphClient.Me().Onenote().ResourcesById(&onenoteResourceId).Content().Get()
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
Import-Module Microsoft.Graph.Notes
# A UPN can also be used as -UserId.
Get-MgUserOnenoteResourceContent -UserId $userId -OnenoteResourceId $onenoteResourceId
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
响应
下面是一个响应示例。
HTTP/1.1 200 OK
Content-Type: application/octet-stream
...binary data...