Id from Batch job result using google ads API

182 views
Skip to first unread message

sowjanya T

unread,
Mar 3, 2022, 5:59:13 AM3/3/22
to Google Ads API and AdWords API Forum
Hi Team,
I am using batch job to add Adgroup to a campaign,but while fetching the ad id always getting 0, even though i added response content type as MUTABLE_RESOURCE.
here is my code,

                        ListBatchJobResultsPagedResponse batchJobResults = batchJobServiceClient
                                        .listBatchJobResults(ListBatchJobResultsRequest.newBuilder().setResourceName(batchJobResourceName)
                                                        .setPageSize(PAGE_SIZE).setResponseContentType(ResponseContentType.MUTABLE_RESOURCE).build());
                        try (AdGroupServiceClient adGroupServiceClient = googleAdsClient.getLatestVersion()
                                        .createAdGroupServiceClient()) {
                                for (BatchJobResult batchJobResult : batchJobResults.iterateAll()) {
                                        // AdGroupAd ad =
                                        // batchJobResult.getMutateOperationResponse().getAdGroupAdResult().getResourceName();
                                        String adGroupResourceName = batchJobResult.getMutateOperationResponse().getAdGroupResult()
                                                        .getResourceName();
                                        LOGGER.info("test batch id....." + batchJobResult.getMutateOperationResponse().getAdGroupResult().getAdGroup().getId());

Google Ads API Forum Advisor

unread,
Mar 4, 2022, 2:12:56 AM3/4/22
to sowjanya.th...@ivycomptech.com, adwor...@googlegroups.com
Hi,

Thank you for posting your concern.

To investigate the issue, could you provide the complete request and response logs with request ID and request header generated on your end?

You can provide it via Reply privately to author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Regards,
Google Logo
Ernie John
Google Ads API Team
 


ref:_00D1U1174p._5004Q2Xl1RD:ref

Elegi Sandi

unread,
Aug 10, 2023, 2:15:55 PM8/10/23
to Google Ads API and AdWords API Forum
for those who are still wondering in 2023, you can parse the resource name using the client you're using (eg: batchjobserviceclient).

I'm using PHP so:

$parsed_resource_name = $batchJobServiceClient->parseName($batch_job_result->getMutateOperationResponse()->getAdGroupResult()->getResourceName());

// the parseName method will return an array containing all the variable segments (enclosed with {}) of a resource string  (eg: customers/{customer_id}/adGroups/{ad_group_id})
// so to get the ad group id, you can do like this:

$parsed_resource_name['ad_group_id']; 

Hope that helps.
Cheers,

Google Ads API Forum Advisor

unread,
Aug 10, 2023, 4:35:58 PM8/10/23
to el...@crowdmetric.com, adwor...@googlegroups.com

Hi Elegi,

Thank you for commenting on this forum thread, and providing insights to parse the resource name. Thank you for contributing to the Google Ads API community.

This message is in relation to case "ref:_00D1U1174p._5004Q2Xl1RD:ref"

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages