如何解决尝试访问共享的一个便笺项时,Microsoft Graph提供“编码的共享URI中的网站无效”
我无法获得Microsoft图形OneDrive Share API来处理从个人Microsoft帐户共享的OneNote文档。共享由个人Microsoft帐户生成的OneNote文档时,将生成https://1drv.ms/u/s!{text}
格式的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();
据我从docs得知这应该可行,任何帮助都值得赞赏。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。