Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Urgent] FinalUrls is READONLY #337

Closed
ullfindsmit opened this issue Dec 21, 2021 · 9 comments
Closed

[Urgent] FinalUrls is READONLY #337

ullfindsmit opened this issue Dec 21, 2021 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@ullfindsmit
Copy link

Describe the bug:
FinalURLs is now readonly so I removed the line and now I get an error when trying to create a new Ad.

In the latest library the FinalUrls property is READONLY
Assembly Google.Ads.GoogleAds, Version=10.2.0.0, Culture=neutral, PublicKeyToken=52807268f2b614dc

However, in the earlier version it was NOT readonly.
Assembly Google.Ads.GoogleAds, Version=10.1.0.0, Culture=neutral, PublicKeyToken=52807268f2b614dc

What is the new way to set the FinalURLs value?

Steps to Reproduce:


                    // Create the ad group ad object.
                    AdGroupAd adGroupAd = new AdGroupAd
                    {
                        AdGroup = oAdGroup,
                        // Optional: Set the status.
                        Status = AdGroupAdStatus.Paused,
                        Ad = new Ad
                        {
                            **FinalUrls = { oAdGroupAd.FinalUrls },**
                            ExpandedTextAd = new ExpandedTextAdInfo
                            {
                                Description = CSVParameterObj.Description,
                                Description2 = CSVParameterObj.Description2,
                                HeadlinePart1 = CSVParameterObj.HeadlinePart1,
                                HeadlinePart2 = CSVParameterObj.HeadlinePart2,
                                HeadlinePart3 = CSVParameterObj.HeadlinePart3,
                                Path1 = CSVParameterObj.Path1,
                                Path2 = CSVParameterObj.Path2
                            }
                        }
                    };

Expected behavior:
Backward compatibility or documentation on how to fix.

Client library version and API version:
Assembly Google.Ads.GoogleAds, Version=10.2.0.0, Culture=neutral, PublicKeyToken=52807268f2b614dc
.NET version: Latest
Operating system (Linux, Windows, ...) and version (if the bug is platform-specific): Windows 10

Request/Response Logs:
{
"StatusCode": 3,
"Details": "Request contains an invalid argument.",
"RequestId": "--removed--",
"Failure": {
"errors": [
{
"errorCode": {
"collectionSizeError": "TOO_FEW"
},
"message": "Too few.",
"location": {
"fieldPathElements": [
{
"fieldName": "operations",
"index": 0
},
{
"fieldName": "create"
},
{
"fieldName": "ad"
},
{
"fieldName": "final_urls"
}
]
}
}
],
"requestId": "--removed--"
}
}

Anything else we should know about your project / environment

Not at the moment.

@jradcliff
Copy link
Member

Hi,

Thanks for opening the issue here. The error you received looks to be due to there being zero final URLs on the ad sent in the request. Does the ad you're copying from (oAdGroupAd) have a non-empty FinalUrls collection?

Thanks

@ullfindsmit
Copy link
Author

Yes, the property FinalUrls collection is blank.
The reason it is blank is because the property FinalURLs used to be read/write in 10.1 and is readonly in 10.2
There is no documentation as to HOW to set the value in 10.2.

@rivdiv
Copy link

rivdiv commented Dec 22, 2021

I am hitting this issue as well with setting the FinalURls property on the AdGroupCriterion object. It is read only in both versions 9 and 10.2 which I just upgraded to.
https://groups.google.com/g/adwords-api/c/gPS2ibFplVY

@vipulpatel007
Copy link

vipulpatel007 commented Dec 23, 2021

ullfindsmit is right.
In Version 10.1 its allow to set value of finalURLs Please check this
Ad Expandend TextAPI

@AnashOommen
Copy link
Member

AnashOommen commented Jan 4, 2022

There seems to be multiple issues being discussed on this thread, so let me go over them one by one.

  1. In C#, repeated fields are treated as readonly lists. So this code should work:
private void TryArrayInitialize()
{
  Ad oAdGroupAd = new Ad();
  string oAdGroup = "";
  AdGroupAd adGroupAd = new AdGroupAd
  {
    AdGroup = oAdGroup,
    // Optional: Set the status.
    Status = AdGroupAdStatus.Paused,
    Ad = new Ad
    {
      FinalUrls = { oAdGroupAd.FinalUrls },
      ExpandedTextAd = new ExpandedTextAdInfo
      {
      }
    }
  };
}

The relevant C# feature is discussed here: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers#object-initializers-with-collection-read-only-property-initialization

  1. The question is why this code stopped working between 10.1 and 10.2. I don't have a good answer to that, because the code hasn't changed between 10.1 and 10.2. So I can't replicate this issue, even though I also don't doubt this might be affecting some users because @friedenberg also ran into this issue once. For reference, here are the files.

public pbc::RepeatedField<string> FinalUrls {
get { return finalUrls_; }
}

public pbc::RepeatedField<string> FinalUrls {
get { return finalUrls_; }
}

Can someone provide a minimal project that helps replicate this issue?

I am using

Microsoft Visual Studio Community 2019
Version 16.11.6
VisualStudio.16.Release/16.11.6+31829.152
Microsoft .NET Framework
Version 4.8.04084

And for command line:

SDK Version: 5.0.404

And OS version:

Windows 10, Microsoft Windows Version 20H2 (OS Build 19042.1415)

The following projects compile fine locally.

Compilation Issues.zip

@AnashOommen AnashOommen self-assigned this Jan 4, 2022
@ullfindsmit
Copy link
Author

ullfindsmit commented Jan 11, 2022 via email

@ullfindsmit
Copy link
Author

ullfindsmit commented Jan 11, 2022 via email

@AnashOommen
Copy link
Member

@ullfindsmit can you please attach a minimal project that illustrates the issue? Or otherwise, confirm if you can compile the attached Compilation Issues.zip?

@ullfindsmit
Copy link
Author

ullfindsmit commented Jan 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants