googleads / google-ads-dotnet

This project hosts the .NET client library for the Google Ads API.

Home Page:https://developers.google.com/google-ads/api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dismiss recommendation issue

nakitadog opened this issue · comments

I am trying to work with this example code:
https://developers.google.com/google-ads/api/samples/dismiss-recommendation#c

The issue that I'm having is the code in that C# example is looking for the following variable: recommendationId which is of the long data type.

There is no recommendationId that are numerical (long). They are all string values.

What am I missing here?

I have tried to send the resource_name to execute the DismissRecommendationOperation, however, it just hangs.

No response is ever received.

It is indeed a bug in the DismissRecommendation example, the recommendation id should be a string instead of a long.

I'll send out a PR about it.

Thanks for noticing!

What about the primary issue?

When I call the service.DismissRecommendation() it just hangs even when I supply a correctly formatted ResourceName?

"customers/{customer_id}/recommendations/{recommendation_id}"

I was able to solve my primary issue with the service.DismissRecommendation().

I did pass a string for the ResourceName, however, I also had to use the Async version of the service.

Here's my example code:

public async void Dismiss_Recommendation_Operation(GoogleAdsClient client, long customerId, string RecommendationResourceName){
    RecommendationServiceClient service = client.GetService(Services.V12.RecommendationService);
    DismissRecommendationOperation operation = new DismissRecommendationOperation(){
        ResourceName = RecommendationResourceName
    };
    try{
        DismissRecommendationResponse response = await service.DismissRecommendationAsync(customerId.ToString(), new DismissRecommendationOperation[] { operation });

        foreach (DismissRecommendationResult result in response.Results)
            Console.WriteLine($"Dismissed recommendation with resource name = [{result.ResourceName}].");
    }
    catch (GoogleAdsException e){
        Console.WriteLine("Failure:");
        Console.WriteLine($"Message: {e.Message}");
        Console.WriteLine($"Failure: {e.Failure}");
        Console.WriteLine($"Request ID: {e.RequestId}");
    }
}

My code is running from a Windows form.

You wrote: "Pls use a sync methods"

Did you mean synchronous or asynchronous?

Thank you for your reply and clarification.

I'll add some additional documentation to clarify the issue with WinForms. This has shown up in at least 4 bugs so far.