我无法让 Microsoft graph OneDrive Share API 处理从个人 Microsoft 帐户共享的 OneNote 文档。https://1drv.ms/u/s!{text}
共享个人 Microsoft 帐户生成的 OneNote 文档时会生成该格式的 URL 。但是我无法使用 Microsoft Graph API。以下代码引发此错误:
Unhandled exception. Status Code: BadRequest
Microsoft.Graph.ServiceException: Code: invalidRequest
Message: The site in the encoded share URI is invalid.
C# 控制台应用程序代码:
IPublicClientApplication publicClientApplication = PublicClientApplicationBuilder
.Create(clientId)
.WithRedirectUri("http://localhost")
.Build();
InteractiveAuthenticationProvider authProvider =
new InteractiveAuthenticationProvider(publicClientApplication, new[] {
"https://graph.microsoft.com/Sites.ReadWrite.All",
"https://graph.microsoft.com/Files.ReadWrite",
"https://graph.microsoft.com/Files.ReadWrite.All"
});
var graphClient = new GraphServiceClient(authProvider);
var sharingUrl = "https://1drv.ms/u/s!...";
string base64Value = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(sharingUrl));
string encodedUrl = "u!" + base64Value.TrimEnd('=').Replace('/', '_').Replace('+', '-');
var shares = await graphClient.Shares[encodedUrl].Permission.Request().GetAsync();
据我从文档中可以看出,这应该可行,任何帮助表示赞赏。