none
Error deleting a student from OneNote classnotebook using API RRS feed

  • Question

  • I am trying to delete a student from a OneNote classnote book using the microsoft onenote API, but getting the following error.

    {'error': {'code': '19999', 'message': 'Something failed, the API cannot share any more information at the time of the request.', '@api.url': 'https://aka.ms/onenote-errors#C19999'}}

    I am using the REST API command documented here https://docs.microsoft.com/en-us/previous-versions/office/office-365-api/how-to/onenote-classnotebook#remove-students-and-teachers

    There isn't a graph API REST call, MS haven't provided any class notebook calls in graph, and the current graph documentation points to the above documentation for dealing with class notebooks.

    Here is my python code

    onenote_url = 'https://www.onenote.com/api/v1.0/me/notes'
    def remove_student_from_notebook( token , studentid , notebookid ):
        client = OAuth2Session(token=token)  
        headers = { 'Authorization': 'Bearer, {}'.format(token), 'Accept': 'application/json' }  
        url = '{0}/classNotebooks/{1}/students/{2}'.format(onenote_url,notebookid,studentid)  
        events = client.delete(url, headers=headers )  
        print( events.json() )

    I know the ids are correct because I can use the exact same ones to add a student to the class notebook without any problems.

    Has anyone got this API to work?

    What am I doing wrong?

    Sunday, January 26, 2020 9:29 AM

All replies

  • I have found the problem. I was using the principleUserName because it is what is returned by a previous API call to get the list of students in a class notebook.

    In my case for some reason the principleUserName is something like 

    'i:0#.f|membership|name@org.co.uk'

    which has special characters so can't form part of the URL the REST API call.

    The solution is to strip of the first part of the principleUserName and only use the email address i.e. name@org.co.uk, then it works.

    BTW adding a student works because the principleUserName is sent as json data to that API call and not encoded in the URL.

    • Edited by eduwaller Monday, January 27, 2020 1:28 PM
    Monday, January 27, 2020 1:21 PM