Google Ads API Java

62 views
Skip to first unread message

Krishna

unread,
Dec 27, 2018, 9:11:10 AM12/27/18
to AdWords API and Google Ads API Forum

Hi,


Is there an api method to print SearchPagedResponse as JSON on the console? If not, any ideas to accomplish that.

Basically looking to retrieve the response as a JSON string.


Thanks,


Krishna

Teja Makani

unread,
Dec 27, 2018, 2:46:19 PM12/27/18
to AdWords API and Google Ads API Forum
Hello Krishna,

In the latest version of Google Ads API beta the SearchPagedResponse consists of number of GoogleAdsRows. A GoogleAdsRow represents an object returned by a query, and consists of a set of attributes that are populated based on the fields requested in the SELECT clause. To know more about GoogleAdsRow please refer this guide. When you print the google Ads row as shown in the below code snippet(for JAVA client library) you will get the result similar to JSON format for each row. If you want to get exact JSON format you can use the CURL operations as shown in the step-5 of this guide otherwise you have to build a JSON object at your end. Please let me know if you have any further questions.  
  
Sample Code snippet from JAVA client library's GetCampaigns.java below:
SearchPagedResponse searchPagedResponse = googleAdsServiceClient.search(request);
for (GoogleAdsRow googleAdsRow : searchPagedResponse.iterateAll()) {
System.out.println(googleAdsRow);
}

Response (Redacted the Ids) below:
campaign {
  resource_name: "customers/123456789/campaigns/123456789"
  id {
    value: 123456789
  }
  name {
    value: "TestCampaign"
  }
  campaign_budget {
    value: "customers/123456789/campaignBudgets/123456789"
  }
  network_settings {
    target_content_network {
      value: true
    }
  }
}

Hope this helps you, please let me know if you have any further questions.

Regards,
Sai Teja, Google Ads API Team

vskadwords

unread,
Dec 27, 2018, 3:03:42 PM12/27/18
to AdWords API and Google Ads API Forum
Thanks Sai Teja. I was printing searchPagedResponse instead of  googleAdsRow.

Is there a limitation on the # of fields in the SELECT clause? Thinking in terms of a huge SELECT operation for all GET requests.

Thanks,

Krishna

Teja Makani

unread,
Dec 28, 2018, 2:11:39 PM12/28/18
to AdWords API and Google Ads API Forum
Hello Krishna,

There wont be any limit on the number of fields on the SELECT operation. If the fields are not compatible then your program may terminate without any errors. 


Regards,
Sai Teja, Google Ads API Team

On Thursday, December 27, 2018 at 9:11:10 AM UTC-5, vskadwords wrote:
Reply all
Reply to author
Forward
0 new messages