Few days ago our applications (iOS, Android and Windows) stopped getting the list of Pages from Microsoft OneNote via OneNote API request https://www.onenote.com/api/v1.0/me/notes/pages. Request returns HTTP OK and empty content. Source code Windows UWP appliaction C#-XAML (from Microsoft OneNote API example https://github.com/OneNoteDev/OneNoteAPISampleWinUniversal)
public static string GET_PAGES_REQEST = APIENDPOINT + "sections/{0}/pages";
public const string APIENDPOINT = "https://www.onenote.com/api/v1.0/me/notes/";
public const string AUTHMETHOD = "Bearer";
public const string APPJSON = "application/json";
/// <summary>
/// Get meta data for ALL pages under a given section
/// </summary>
/// <param name="sectionId">Id of the section for which the page are returned</param>
/// <param name="token">Authentication token</param>
/// <param name="isEncryptedOnly">View encrypted only notes</param>
/// <remarks> The sectionId can be fetched by querying the user's sections (e.g. GET https://www.onenote.com/api/v1.0/sections ).
/// NOTE: Using this approach, you can still query pages with ALL the different params shown in examples above.
/// </remarks>
/// <returns>The converted HTTP response message</returns>
public static async Task<List<PageApiResponse>> GetListAsync(string sectionId, string token, bool isEncryptedOnly)
{
var client = new HttpClient();
// Note: API only supports JSON response.
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(Common.APPJSON));
//client.DefaultRequestHeaders.Add("FavorDataRecency", "true");
// Not adding the Authentication header would produce an unauthorized call and the API will return a 401
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue
(
Common.AUTHMETHOD, token
);
// Prepare an HTTP GET request to the Pages endpoint
var getMessage = new HttpRequestMessage
(
HttpMethod.Get,
isEncryptedOnly ?
String.Format(Common.GET_PAGES_ENCRYPTED_REQEST, sectionId) :
String.Format(Common.GET_PAGES_REQEST, sectionId)
);
HttpResponseMessage response = await client.SendAsync(getMessage);
string body = await response.Content.ReadAsStringAsync();
if (response.StatusCode != HttpStatusCode.OK)
throw new Exception(Errors.TranslateError(response));
var content = JObject.Parse(body);
return JsonConvert.DeserializeObject<List<PageApiResponse>>(content["value"].ToString());
}
sectionId and token is correct. isEncryptedOnly = false;
Notebooks and Sections work fine. Anybody can help me?