Skip to content

Commit bb22741

Browse files
authored
Merge pull request #28 from OneNoteDev/add-getnotebookfromweburl-method
Adding getNotebookFromWebUrl
2 parents a7cb897 + 19898f5 commit bb22741

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.10",
2+
"version": "2.0.11",
33
"name": "onenoteapi",
44
"description": "JavaScript library to make calling the OneNote API easier.",
55
"main": "dist/OneNoteApi.js",

src/scripts/iOneNoteApi.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ export interface IOneNoteApi {
2020
pagesSearch(query: string): Promise<ResponsePackage<any>>;
2121
performApiCall(url: string, data?: XHRData, contentType?: string, httpMethod?: string, isFullUrl?: boolean, urlContainsVersion?: boolean): Promise<ResponsePackage<any>>;
2222
getNotebooksFromWebUrls(notebookWebUrls: string[]): Promise<ResponsePackage<any>>;
23+
getNotebookFromWebUrl(notebookWebUrl: string): Promise<ResponsePackage<any>>;
2324
}

src/scripts/oneNoteApi.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@ export class OneNoteApi extends OneNoteApiBase implements IOneNoteApi {
6666
return returnValue;
6767
}
6868

69+
/**
70+
* GetNotebookFromWebUrl
71+
*/
72+
public getNotebookFromWebUrl(notebookWebUrl: string): Promise<ResponsePackage<any>> {
73+
let url = "/me/notes/notebooks/Microsoft.OneNote.Api.GetNotebookFromWebUrl()";
74+
const payload = {
75+
webUrl: notebookWebUrl
76+
};
77+
78+
const oldUseBetaApi = this.useBetaApi;
79+
this.useBetaApi = true; // This API is only supported in beta
80+
const returnValue = this.requestPromise(url, JSON.stringify(payload));
81+
this.useBetaApi = oldUseBetaApi;
82+
return returnValue;
83+
}
84+
6985
/**
7086
* SendBatchRequest
7187
**/

0 commit comments

Comments
 (0)