使用 OneNote 需要有企业账号吗API

Is it necessary to have business account for use OneNote API

我正在使用 Microsoft Graph 开发应用程序,并且正在使用 OneNote 测试一些基本功能。我可以使用用户,但在涉及到 OneNote 时,我收到有关 SharePoint 许可证的错误。

我收到的错误: { "error":{ "code": "30121", "message": "The tenant does not have a valid SharePoint license.", "innerError":{ "request-id": "12d9555f-ab42-43d6-a5ad-ed4be2fe0c93", "date":“2019-11-11T12:58:55” } } }

如果我已经拥有 Office for Home,是否需要购买 Office of Business,如果不需要,我该如何解决这个错误?

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

这是我的代码 运行:

public class X
{
    public void thing()
    {
        static void Main(string[] args)
        {
            Task<string> task = GetAccessToken();
            task.Wait();

            var token = task.Result;
            Console.WriteLine(token);

            Task<string> usersTask = GetUser(token);
            usersTask.Wait();

            var user = usersTask.Result;
            Console.WriteLine(user);

            Task<string> notesTask = GetNotes(token, user); //GetEmail(token, user);
            notesTask.Wait();

            var notes = notesTask.Result;
            Console.WriteLine(notes);

            Console.ReadKey();
        }

        static async Task<string> GetAccessToken()
        {
            string token = "";
            StringContent content =
                new StringContent($"client_id={clientId}&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default&client_secret={appKey}&grant_type=client_credentials", Encoding.UTF8, "application/x-www-form-urlencoded");
            using(var response = await httpClient.PostAsync($"https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token", content))
            {
                if (response.IsSuccessStatusCode)
                {
                    dynamic result = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
                    token = result.access_token;
                }
            }

            return token;
        }

        static async Task<string> GetUser(string token)
        {
            string user = "";
            httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

            using(var response = await httpClient.GetAsync($"https://graph.microsoft.com/v1.0/users"))
            {
                if (response.IsSuccessStatusCode)
                {
                    var res = await response.Content.ReadAsStringAsync();
                    dynamic users = JsonConvert.DeserializeObject(res);
                    return users.value[1].id;
                }
            }

            return user;
        }

        static async Task<string> GetNotes(string token, string userId)
        {
            var data = "";
            httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

            using(var response = await httpClient.GetAsync($"https://graph.microsoft.com/v1.0/users/{userId}/onenote/notebooks"))
            {
                if (response.IsSuccessStatusCode) //error
                {
                    var res = await response.Content.ReadAsStringAsync();
                    return res;
                }
            }

            return data;
        }
    }
}

当您尝试访问基于云的 information/notebooks 时,您需要一个 Office 365 subscription

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

还有使用 ...

的选项