Hi, 

I was migrating from v8 to v10. getCustomer method is now removed from 
customer service. And it was mentioned to use SearchStream instead. 

For a SearchStream request, customer id is a required parameter. The query 
returns value only if the customer id in SearchStream request is same as 
the the customer id which is to be searched. 

Below is the code, and you can notice that the customer id is same. 
I have tried setting the customer id in SearchGoogleAdsStreamRequest as 
client.getLinkedCustomerId() and client.getLoginCustomerId(), but the query 
works only with the customer id we want to search. 

Please let me know whether I am using SearchGoogleAdsStreamRequest the 
correct way for Customer. 

public Customer getCustomer(GoogleAdsClient client, long customerId) {
String query = "SELECT customer.auto_tagging_enabled, 
customer.call_reporting_setting.call_conversion_action, 
customer.call_reporting_setting.call_conversion_reporting_enabled, 
customer.call_reporting_setting.call_reporting_enabled, 
customer.conversion_tracking_setting.accepted_customer_data_terms, 
customer.conversion_tracking_setting.conversion_tracking_id, 
customer.conversion_tracking_setting.conversion_tracking_status, 
customer.conversion_tracking_setting.cross_account_conversion_tracking_id, 
customer.conversion_tracking_setting.enhanced_conversions_for_leads_enabled, 
customer.currency_code, customer.descriptive_name, 
customer.final_url_suffix, customer.has_partners_badge, customer.id, 
customer.manager, customer.optimization_score, 
customer.optimization_score_weight, 
customer.pay_per_conversion_eligibility_failure_reasons, 
customer.remarketing_setting.google_global_site_tag, 
customer.resource_name, customer.status, customer.test_account, 
customer.time_zone, customer.tracking_url_template FROM customer WHERE 
customer.id = "+customerId;
try (GoogleAdsServiceClient gadsService =
client.getLatestVersion().createGoogleAdsServiceClient()) {
SearchGoogleAdsStreamRequest request =
SearchGoogleAdsStreamRequest.newBuilder()
.setCustomerId(String.valueOf(customerId))
.setQuery(query)
.build();

ServerStream<SearchGoogleAdsStreamResponse> streamResponse =
gadsService.searchStreamCallable().call(request);

List<GoogleAdsRow> results = new ArrayList<>();
for (SearchGoogleAdsStreamResponse response : streamResponse) {
results.addAll(response.getResultsList());
}

return results.stream().map(row -> row.getCustomer()).collect(Collectors.
toList()).get(0);
}
}

Thanks and Regards,
Muthu Qumar S.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/b0a0adc0-b8e4-4e06-b0ca-53f962a15447n%40googlegroups.com.

Reply via email to