googleads / google-ads-dotnet

This project hosts the .NET client library for the Google Ads API.
https://developers.google.com/google-ads/api
Apache License 2.0
73 stars 97 forks source link

Can reports show the field names in the result? #13

Closed Zweitze closed 5 years ago

Zweitze commented 6 years ago

One of the first apps I write is a simple report viewer: a Windows Forms application allowing the user to set up a report, has a button Go and a GridView showing the results. Once succeeded it proves very helpful by allowing you to test combinations of fields, to see which values can occur in the response etc.etc.

Unfortunately the result of googleAdsService.Search() contains all possible fields, which are hundreds. Can a list of fields be published too? Note: you would think parsing the query text should reveal the names. Unfortunately the query text uses different names than the resulting report, also see issue #12

AnashOommen commented 6 years ago

Hi Zwitze,

I don't quite understand the issue. Just like in AdWords API, Google Ads API will only return fields that you requested.

E.g. See GetCampaigns.cs example. you get back only the fields you requested.

Is your ask for the server to return the list of field that were requested, as part of GoogleAdsRow? I assume, you are asking for the field_mask property in SearchGoogleAdsResponse? If yes, I'll follow up with an example on how to retrieve it.

AnashOommen commented 6 years ago

Hi Zwitze,

You could write the code like this:

// Issue the search request.
PagedEnumerable<SearchGoogleAdsResponse, GoogleAdsRow> searchPagedResponse =
    googleAdsService.Search(request);

foreach (SearchGoogleAdsResponse response in searchPagedResponse.AsRawResponses())
{
    Console.WriteLine(response.FieldMask);
    foreach (GoogleAdsRow googleAdsRow in response.Results)
    {
        Console.WriteLine("Campaign with ID {0} and name '{1}' was found.",
            googleAdsRow.Campaign.Id, googleAdsRow.Campaign.Name);

    }
}
Zweitze commented 6 years ago

Yes, method AsRawResponses() of the result is what I was looking for. And I do like that this result uses the same names as requested, meaning easier matching. Is SearchGoogleAdsResponse documented somewhere?

(I know, the package states HTML and XML docs are available, but I can't find it. Please help me out)

AnashOommen commented 5 years ago

HI Zweitze,

Apologies for the delay, I didn't realize you were waiting on me for additional details. The online docs are here: https://developers.google.com/google-ads/api/reference/rpc/google.ads.googleads.v0.services#google.ads.googleads.v0.services.SearchGoogleAdsResponse