'Python > O365 > Mailbox Query > how to filter by email category
I have managed to get queries working with O365 for normal fields like sender, flag etc but I can't figure out how to query a list field.
I have tried
query = mailbox.new_query().on_attribute('categories').contains('Expenses')
but this results in
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://graph.microsoft.com/beta/me/mailFolders/Inbox/messages?%24top=30&%24filter=contains%28categories%2C+%27Expenses%27%29+and+createdDateTime+gt+2022-02-25T00%3A00%3A00%2B00%3A00 | Error Message: Invalid filter clause
There seems to be an on_list_field method but I cant figure out how that should be used.
for example:
query = mailbox.new_query().on_list_field('categories').contains('Expenses')
results in
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://graph.microsoft.com/beta/me/mailFolders/Inbox/messages?%24top=30&%24filter=contains%28fields%2Fcategories%2C+%27Expenses%27%29 | Error Message: Could not find a property named 'fields' on type 'microsoft.graph.message'.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
