C# 是否需要使用OneNote API的业务帐户

C# 是否需要使用OneNote API的业务帐户,c#,microsoft-graph-api,onenote-api,C#,Microsoft Graph Api,Onenote Api,我正在使用Microsoft Graph开发一个应用程序,并正在使用OneNote测试一些基本功能。我可以使用用户,但在OneNote方面,我遇到了有关SharePoint许可证的错误 我收到的错误: { “错误”:{ “代码”:“30121”, “消息”:“租户没有有效的SharePoint许可证。”, “内部错误”:{ “请求id”:“12d9555f-ab42-43d6-a5ad-ed4be2fe0c93”, “日期”:“2019-11-11T12:58:55” } } } 如果家里已经有

我正在使用Microsoft Graph开发一个应用程序,并正在使用OneNote测试一些基本功能。我可以使用用户,但在OneNote方面,我遇到了有关SharePoint许可证的错误

我收到的错误: { “错误”:{ “代码”:“30121”, “消息”:“租户没有有效的SharePoint许可证。”, “内部错误”:{ “请求id”:“12d9555f-ab42-43d6-a5ad-ed4be2fe0c93”, “日期”:“2019-11-11T12:58:55” } } }

如果家里已经有办公室,我是否需要购买Office of Business?如果没有,我如何解决此错误

根据,我需要一个Office 365业务订阅,但我仍然不清楚为什么它应该包括SharePoint

这是我正在运行的代码:

公共类X
{
公物
{
静态void Main(字符串[]参数)
{
任务Task=GetAccessToken();
task.Wait();
var token=task.Result;
控制台写入线(令牌);
任务usersTask=GetUser(令牌);
usersTask.Wait();
var user=usersTask.Result;
Console.WriteLine(用户);
Task notesTask=GetNotes(令牌,用户);//GetEmail(令牌,用户);
notesTask.Wait();
var notes=notesTask.Result;
控制台写入线(注释);
Console.ReadKey();
}
静态异步任务GetAccessToken()
{
字符串标记=”;
字符串内容=
新的StringContent($“客户端id={clientId}&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client\u secret={appKey}&grant\u type=client\u凭证”,Encoding.UTF8,“应用程序/x-www-form-urlencoded”);
使用(var response=wait-httpClient.PostAsync($)https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token”,内容)
{
if(响应。IsSuccessStatusCode)
{
动态结果=JsonConvert.DeserializeObject(wait response.Content.ReadAsStringAsync());
令牌=result.access\u令牌;
}
}
返回令牌;
}
静态异步任务GetUser(字符串令牌)
{
字符串user=“”;
httpClient.DefaultRequestHeaders.Authorization=新系统.Net.Http.Headers.AuthenticationHeaderValue(“承载者”,令牌);
使用(var response=wait-httpClient.GetAsync($)https://graph.microsoft.com/v1.0/users"))
{
if(响应。IsSuccessStatusCode)
{
var res=await response.Content.ReadAsStringAsync();
动态用户=JsonConvert.DeserializeObject(res);
返回users.value[1].id;
}
}
返回用户;
}
静态异步任务GetNotes(字符串令牌、字符串用户ID)
{
var数据=”;
httpClient.DefaultRequestHeaders.Authorization=新系统.Net.Http.Headers.AuthenticationHeaderValue(“承载者”,令牌);
使用(var response=wait-httpClient.GetAsync($)https://graph.microsoft.com/v1.0/users/{userId}/onenote/Notebook”))
{
if(response.issucessStatusCode)//错误
{
var res=await response.Content.ReadAsStringAsync();
返回res;
}
}
返回数据;
}
}
}

当您试图访问基于云的信息/笔记本电脑时,您需要一个

OneNote笔记本存储在Office 365中的Sharepoint上


还可以选择使用…

显示用于调用API的代码,但不显示返回的响应。OneNote API支持工作帐户和个人帐户,但如果看不到响应,则很难诊断。@Marclafler,{“错误”:{“代码”:“30121”,“消息”:“租户没有有效的SharePoint许可证”,“内部错误”:{“请求id”:“10f50974-e056-4feb-b9aa-4ca99a02d10e”,“日期”:“2019-11-11T12:51:56”