Closed ullfindsmit closed 2 years ago
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
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.
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
ullfindsmit is right. In Version 10.1 its allow to set value of finalURLs Please check this
There seems to be multiple issues being discussed on this thread, so let me go over them one by one.
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
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.
@AnashOommen thank you for staying on this issue. The issue is that the FinalURLs property is ReadOnly in 10.2.0.0 and I am not able to set its value as you suggested
FinalUrls = { oAdGroupAd.FinalUrls }
[image: image.png]
@ullfindsmit can you please attach a minimal project that illustrates the issue? Or otherwise, confirm if you can compile the attached Compilation Issues.zip?
I was finally able to get it to work. The solution was to not use the inline declaration but instead to create a new Ad object Then instead of assigning the final urls, simply using oAd.FinalURLs.Add("string")
Message ID: @.***>
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:
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.