I'm trying to make batched requests more efficient by getting partial responses. I'm interested to get just certain headers (from, to, subject) and the message body.
My code works fine when I run it like this:
$client = getClient();
$client->setUseBatch(true);
$service = new Google_Service_Gmail($client);
$batch = new Google_Http_Batch($client, false, null, 'batch/gmail/v1');
$request1 = $service->users_messages->get('me', '17eb57d85dd4933d', ['format'=>'full', 'fields' => 'id,snippet,payload(headers(name,value),body,parts)']);
$request2 = $service->users_messages->get('me', '17eb4fe58a1b3be6', ['format'=>'full', 'fields' => 'id,snippet,payload(headers(name,value),body,parts)']);
$batch->add($request1, "message" . '-17eb57d85dd4933d');
$batch->add($request2, "message" . '-17eb4fe58a1b3be6');
$result = $batch->execute();
var_dump($result);
As you can see in the above request, I'm getting ALL the header name, value pairs as payload(headers(name,value). But when I change the code to select only certain headers (I'm interested only in From, To, Subject).
$request1 = $service->users_messages->get('me', '17eb57d85dd4933d', ['format'=>'full', 'fields' => 'id,snippet,payload(headers(name,value)[name=From,To,Subject],body,parts)']);
The API throws me an error:
Invalid FieldMask 'id,snippet,payload(headers(name,value)[name=From,To,Subject],body,parts)'. Map keys should be represented as ["some_key"].
I tried changing it to headers(name,value)[name="From",name="To",name="Subject"] and a few other formats but cannot figure out how to get it right. The API documentation too doesn't go in-depth to discuss how to select specific headers in key-value pairs so some help would be appreciated. Thanks.
I'm trying to make batched requests more efficient by getting partial responses. I'm interested to get just certain headers (from, to, subject) and the message body.
My code works fine when I run it like this:
As you can see in the above request, I'm getting ALL the header name, value pairs as
payload(headers(name,value). But when I change the code to select only certain headers (I'm interested only in From, To, Subject).The API throws me an error:
I tried changing it to
headers(name,value)[name="From",name="To",name="Subject"]and a few other formats but cannot figure out how to get it right. The API documentation too doesn't go in-depth to discuss how to select specific headers in key-value pairs so some help would be appreciated. Thanks.