notebook: copyNotebook
Article
02/03/2022
2 minutes to read
10 contributors
In this article
Namespace: microsoft.graph
Copies a notebook to the Notebooks folder in the destination Documents library. The folder is created if it doesn't exist.
For Copy operations, you follow an asynchronous calling pattern: First call the Copy action, and then poll the operation endpoint for the result.
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.Create, Notes.ReadWrite, Notes.ReadWrite.All
Delegated (personal Microsoft account)
Notes.Create, Notes.ReadWrite
Application
Notes.ReadWrite.All
HTTP request
POST /me/onenote/notebooks/{id}/copyNotebook
POST /users/{id | userPrincipalName}/onenote/notebooks/{id}/copyNotebook
POST /groups/{id}/onenote/notebooks/{id}/copyNotebook
Name
Type
Description
Authorization
string
Bearer {token}. Required.
Content-Type
string
application/json
Request body
In the request body, provide a JSON object that contains the parameters that your operation needs. It's okay to send an empty body if none are needed.
Parameter
Type
Description
groupId
String
The id of the group to copy to. Use only when copying to a Microsoft 365 group.
renameAs
String
The name of the copy. Defaults to the name of the existing item.
Response
If successful, this method returns a 202 Accepted
response code and an Operation-Location
header. Poll the Operation-Location endpoint to get the status of the copy operation .
Example
Here is an example of how to call this API.
Request
Here is an example of the request.
POST https://graph.microsoft.com/v1.0/me/onenote/notebooks/{id}/copyNotebook
Content-type: application/json
{
"groupId": "groupId-value",
"renameAs": "renameAs-value"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var groupId = "groupId-value";
var renameAs = "renameAs-value";
await graphClient.Me.Onenote.Notebooks["{notebook-id}"]
.CopyNotebook(groupId,renameAs,null,null,null)
.Request()
.PostAsync();
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 onenoteOperation = {
groupId: 'groupId-value',
renameAs: 'renameAs-value'
};
await client.api('/me/onenote/notebooks/{id}/copyNotebook')
.post(onenoteOperation);
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/notebooks/{id}/copyNotebook"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
NSString *groupId = @"groupId-value";
payloadDictionary[@"groupId"] = groupId;
NSString *renameAs = @"renameAs-value";
payloadDictionary[@"renameAs"] = renameAs;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
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.
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
String groupId = "groupId-value";
String renameAs = "renameAs-value";
graphClient.me().onenote().notebooks("{id}")
.copyNotebook(NotebookCopyNotebookParameterSet
.newBuilder()
.withGroupId(groupId)
.withRenameAs(renameAs)
.withNotebookFolder(null)
.withSiteCollectionId(null)
.withSiteId(null)
.build())
.buildRequest()
.post();
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)
requestBody := msgraphsdk.New()
groupId := "groupId-value"
requestBody.SetGroupId(&groupId)
renameAs := "renameAs-value"
requestBody.SetRenameAs(&renameAs)
notebookId := "notebook-id"
result, err := graphClient.Me().Onenote().NotebooksById(¬ebookId).CopyNotebook(notebook-id).Post(requestBody)
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
Import-Module Microsoft.Graph.Users.Actions
$params = @{
GroupId = "groupId-value"
RenameAs = "renameAs-value"
}
# A UPN can also be used as -UserId.
Copy-MgUserOnenoteNotebook -UserId $userId -NotebookId $notebookId -BodyParameter $params
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 202 Accepted