0
votes

I'm trying to get user incoming messages (emails) by calling list messages endpoint and filter out the mails he sent.

The problem is that the user mail address starts with # (i.e. the mail is something like #[email protected]) and so when sending the request to the full url:

url = "https://graph.microsoft.com/v1.0/Users/{user_id}/messages?$filter=sender/emailAddress/address ne '#[email protected]'"

I'm getting back a 400 (bad request) status code saying "Invalid filter clause"

If I remove the # then the request works (getting back 200) but then I might get mails where the sender is the user itself (i.e. #[email protected]).

Is there a workaround using GRAPH API? (I'm aware of the possibility to filter mails by myself after getting response.. that's not what I'm looking for..)

Thanks

1
Did you try to use encoded value for #? %23user2250152
@user2250152 no, but I think I found the solution - to add ' before the special character (in my case, #) so if I change the filter to be .. ne ''#[email protected]' then it seems to work fine.Noam
Glad to hear @Noam. Move your answer below. So it can be useful to others as well.Dev

1 Answers

0
votes

I think I found the solution - to add ' before the special character (in my case, #) so if I change the filter to be .. ne ''#[email protected]' then it seems to work fine.