Response Metadata

The PHP client library logs the response metadata, including a request ID, by default. Alternatively, you can obtain the response metadata programmatically when calling client service methods by setting the optional parameter withResponseMetadata to true.

Here is an example of sending a query to GoogleAdsService.SearchStream() and setting withResponseMetadata to true:

[$response, $metadata] = $googleAdsServiceClient->searchStream(
    ['withResponseMetadata' => true]

An array is returned, with $response consisting of the query's results from SearchGoogleAdsStreamResponse.

The second member in the array, $metadata, holds the response metadata in the metadata field, which itself is an array:

object(Google\Ads\GoogleAds\Lib\V17\GoogleAdsResponseMetadata)#51 (1) {
  array(17) {
    array(1) {
      string(10) "attachment"
    array(1) {
      string(22) "REQUEST_ID"

You can retrieve the request ID from the request-id key, similarly to using GoogleAdsResponseMetadata::getRequestId().