0
votes

I am using HTTP requests via an Oracle database to extract data from Gmail APIs. In Oracle, you apply all filters to either the URL of the request or its body. This is working fine for simple requests such as the URL below to request list of unread messages in inbox for user: https://gmail.googleapis.com/gmail/v1/users/me/messages?maxResults=500&q=is:unread&labelIds=INBOX

If I try to add more than one filter to the URL (or LabelIds) like in the URL below, I get an error response from the request: https://gmail.googleapis.com/gmail/v1/users/me/messages?maxResults=500&q=is:unread newer_than:2d&labelIds=INBOX

I have tried multiple iterations for "q=" part like using double quotes, but anything I try outside of 1 filter returns an error response.

The documentation at https://developers.google.com/gmail/api/guides/filtering give this filtering example, but that clearly doesn't work for me: https://www.googleapis.com/gmail/v1/users/me/messages?q=in:sent after:2014/01/01 before:2014/02/01

I tried removing the "is:unread" filter and adding it as a label, but I get a similar issue when trying to use multiple labelIds in the URL request. Using just labelIds=INBOX works fine, but using labelIds=INBOX,UNREAD or various iterations of that with quotes and square brackets all return error responses.

How do I use multiple filters (and/or multiple labelIds) in the URL of a request?

Thanks, Dick

1
test it in the search bar on gmail if you can get it to work there then just send it as the q parm to the apiDaImTo
Yeah, when I use "is:unread newer_than:2d" in the Gmail search bar, it works fine but not via the q parameter in the API request; it is returning an error response saying "Your client has issued a malformed or illegal request.".Dick Doyle
Yes, the docs do say it should work, but it doesn't; at least, not when I try it. If I am doing something wrong in my request, I cannot see it. As I mentioned, I am just sending the query as part of URL in the request (e.g. gmail.googleapis.com/gmail/v1/users/me/… newer_than:2d&labelIds=INBOX), but I am getting error responses.Dick Doyle

1 Answers

0
votes

It looks like the problem is with the space between each filter in the q section. If I add %20 for the space, it works.

For example, "https://gmail.googleapis.com/gmail/v1/users/me/messages?maxResults=500&q=is:unread newer_than:2d&labelIds=INBOX" will not work, but "https://gmail.googleapis.com/gmail/v1/users/me/messages?maxResults=500&q=is:unread%20newer_than:2d&labelIds=INBOX" will work.