Home > Software design >  How to use gmail API's Query? Setting property Q seems to be not effect
How to use gmail API's Query? Setting property Q seems to be not effect

Time:11-16

I am using gmail API, all is working except query, the Q property.

// service.Users.Messages.List("me").Q = $"subject:(my search term)";
var response = service.Users.Messages.List("me").Execute();

gives back all messages, no matter if the preceding statement are commented out or executed.

I also examined the request with fiddler, and no traces of any query parameter or something in the GET request... no difference compared to queryless request.

CodePudding user response:

You appear to have part of your request commented out for one. Second optional parms need to be set in the manner below.

var request = service.Users.Messages.List("me");
request.Q = "subject:test";
var response = request.Execute();

To figuer out how to use the Q parm its best to test it in Gmail web app. The text you would send would be exactly the same

enter image description here

  • Related