Search code examples
onenoteonenote-api

Unable to filter notebooks on userRole


I'm trying to get a list of notebooks that I own, my API call is: /me/notes/notebooks?filter=userRole eq 'Owner' (Using the API console, so not replacing spaces here)

The response includes

400 (Bad Request) The OData query is invalid. A binary operator with incompatible types was detected. Found operand types 'Microsoft.OneNote.Api.UserRole' and 'Edm.String' for operator kind 'Equal'

Without the quotes around the userRole filter we get:

400 (Bad Request) Unknown property name: 'Owner' /me/notes/notebooks?filter=userRole eq Owner

Is there a correct way to filter on userRole?

Edit:

Clutching at straws, but I've also tred

/me/notes/notebooks?filter=userRole eq Microsoft.OneNote.Api.UserRole.Owner

Unsuccessfully...

{
  "error": {
    "code": "20143",
    "message": "The OData query is invalid. The child type 'Microsoft.OneNote.Api.UserRole.Owner' in a cast was not an entity type. Casts can only be performed on entity types.",
    "@api.url": "http://aka.ms/onenote-errors#C20143"
  }
}

Solution

  • me/notes/notebooks?$filter=userRole%20eq%20Microsoft.OneNote.Api.UserRole%27Reader%27
    

    Works!