I'm working on a function that takes an existing label and applies it to
selected ad groups (using their ad group ids). Not sure if I'm setting this
up right since I keep getting exceptions, ex:
NameValueType
▶ Failure {{ "errors": [ { "errorCode": { "newResourceCreationError":
"CANNOT_SET_ID_FOR_CREATE" }, "message": "Do not set the id field while
creating new resources.", "trigger": { "int64Value": "1052616624" },
"location": { "fieldPathElements": [ { "fieldName": "operations", "index":
"0" }, { "fieldName": "create" }, { "fieldName": "resource_name" } ] } } ]
}} Google.Ads.GoogleAds.V1.Errors.GoogleAdsFailure
This is the resource name:
"customers/9878485465/adGroupLabels/54654643~459484545"
Can someone take a look at this and tell me what I'm doing wrong
AdGroupLabel adGroupLabel = new AdGroupLabel();
adGroupLabel.ResourceName = ResourceNames.AdGroupLabel(long.
Parse(client.Config.LoginCustomerId), id, long.Parse("459484545"));
// Create the operation.
AdGroupLabelOperation operation = new AdGroupLabelOperation
()
{
Create = adGroupLabel
};
//AdGroup adGroup = new AdGroup();
//adGroup.ResourceName =
ResourceNames.AdGroup(client.Config.LoginCustomerId.ToString(),
// id);
//AdGroupOperation operation = new AdGroupOperation()
//{
// Update = adGroup,
// UpdateMask = FieldMasks.AllSetFieldsOf(adGroup)
//};
try
{
// Update the ad group.label
MutateAdGroupLabelsResponse retVal = adGroupLabelService
.MutateAdGroupLabels(
client.Config.LoginCustomerId.ToString(), new
AdGroupLabelOperation[] { operation });
// Display the results.
MutateAdGroupLabelResult adGroupLabelResult = retVal.
Results[0];
Console.WriteLine($"Ad group with resource name
'{adGroupLabelResult.ResourceName}' " +
"was updated.");
}
catch (GoogleAdsException e)
{
Console.WriteLine("Failure:");
Console.WriteLine($"Message: {e.Message}");
Console.WriteLine($"Failure: {e.Failure}");
Console.WriteLine($"Request ID: {e.RequestId}");
}
}
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/c30eca6c-0db2-41d6-9ed4-c13ea3e3c9b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.