0
votes

How come this is working https://graph.microsoft.com/v1.0/me/onenote/notebooks?filter=tolower(name) eq 'my notebook'

Screenshot from Graph Explorer

and when I try to code the same in C#, I am getting the below error Code: BadRequest Message: Invalid filter clause Inner error: AdditionalData: date: 2020-09-02T20:01:24

I'm using the below code.

var NoteBook = await GraphClient.Me.Onenote.Notebooks.Request().Filter($"name eq 'My Notebook'").GetAsync();

1

1 Answers

0
votes

It's not working with https://graph.microsoft.com/v1.0/me/onenote/notebooks?filter=tolower(name) eq 'my notebook'. You missed a $ before filter=xxx.

The correct one should be https://graph.microsoft.com/v1.0/me/onenote/notebooks?$filter=tolower(displayName) eq 'my notebook'.

There is not a property named name. You can get the result because the filter doesn't take effect. You list all the notebooks. The correct one is displayName.

But in SDK there is not an attribute name defined in notebook class. That's why you get the error while using SDK.

In SDK you should use this code:

var NoteBook = await graphClient.Me.Onenote.Notebooks.Request().Filter($"displayName eq 'My Notebook'").GetAsync();