Update page
Article
11/16/2021
2 minutes to read
10 contributors
In this article
Namespace: microsoft.graph
Update the content of a OneNote page.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Notes.ReadWrite, Notes.ReadWrite.All
Delegated (personal Microsoft account)
Notes.ReadWrite
Application
Notes.ReadWrite.All
HTTP request
PATCH /me/onenote/pages/{id}/content
PATCH /users/{id | userPrincipalName}/onenote/pages/{id}/content
PATCH /groups/{id}/onenote/pages/{id}/content
PATCH /sites/{id}/onenote/pages/{id}/content
Name
Type
Description
Authorization
string
Bearer {token}. Required.
Content-Type
string
application/json
Request body
In the request body, supply an array of patchContentCommand objects that represent the changes to the page. For more information and examples, see Update OneNote pages .
Response
If successful, this method returns a 204 No Content
response code. No JSON data is returned for a PATCH request.
Example
Request
Here is an example of the request.
PATCH https://graph.microsoft.com/v1.0/me/onenote/pages/{id}/content
Content-type: application/json
[
{
'target':'#para-id',
'action':'insert',
'position':'before',
'content':'<img src="image-url-or-part-name" alt="image-alt-text" />'
},
{
'target':'#list-id',
'action':'append',
'content':'<li>new-page-content</li>'
}
]
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var stream = new System.IO.MemoryStream(Encoding.UTF8.GetBytes(@"[
{
'target':'#para-id',
'action':'insert',
'position':'before',
'content':'<img src=""image-url-or-part-name"" alt=""image-alt-text"" />'
},
{
'target':'#list-id',
'action':'append',
'content':'<li>new-page-content</li>'
}
]
"));
var pages = new OnenotePage();
pages.Content = stream;
await graphClient.Me.Onenote.Pages["{onenotePage-id}"]
.Request()
.UpdateAsync(pages);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
const options = {
authProvider,
};
const client = Client.init(options);
const stream = [
{
\'target\':\'#para-id\',
\'action\':\'insert\',
\'position\':\'before\',
\'content\':\'<img src='image-url-or-part-name' alt='image-alt-text' />\'
},
{
\'target\':\'#list-id\',
\'action\':\'append\',
\'content\':\'<li>new-page-content</li>\'
}
];
await client.api('/me/onenote/pages/{id}/content')
.update(stream);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/onenote/pages/{id}/content"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableArray *streamList = [[NSMutableArray alloc] init];
MSGraphStream *stream = [[MSGraphStream alloc] init];
[stream setTarget:@"#para-id"];
[stream setAction:@"insert"];
[stream setPosition:@"before"];
[stream setContent:@"<img src=\"image-url-or-part-name\" alt=\"image-alt-text\" />"];
[streamList addObject: stream];
MSGraphStream *stream = [[MSGraphStream alloc] init];
[stream setTarget:@"#list-id"];
[stream setAction:@"append"];
[stream setContent:@"<li>new-page-content</li>"];
[streamList addObject: stream];
NSError *error;
NSData *streamData = [stream getSerializedDataWithError:&error];
[urlRequest setHTTPBody:streamData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LinkedList<Stream> streamList = new LinkedList<Stream>();
Stream stream = new Stream();
stream.target = "#para-id";
stream.action = "insert";
stream.position = "before";
stream.content = "<img src=\"image-url-or-part-name\" alt=\"image-alt-text\" />";
streamList.add(stream);
Stream stream1 = new Stream();
stream1.target = "#list-id";
stream1.action = "append";
stream1.content = "<li>new-page-content</li>";
streamList.add(stream1);
graphClient.customRequest("/me/onenote/pages/{id}/content", Stream.class)
.buildRequest()
.patch(stream);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
onenotePageId := "onenotePage-id"
graphClient.Me().Onenote().PagesById(&onenotePageId).Content().Patch()
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
Response
Here is an example of the response.
HTTP/1.1 204 No Content