Hi Sam,

Can you confirm if you are using BatchJobService 
<https://developers.google.com/adwords/api/docs/reference/v201809/BatchJobService>
 to 
add labels to your keywords? Please note that LabelOperation 
<https://developers.google.com/adwords/api/docs/reference/v201809/LabelService.LabelOperation>
 is 
not a supported operation 
<https://developers.google.com/adwords/api/docs/guides/batch-jobs#supported_operations>
 by 
BatchJobService. If you're indeed using BatchJobService, you may get all of 
the label_id first and then use these as temporary Id 
<https://developers.google.com/adwords/api/docs/guides/batch-jobs#using_temporary_ids>s
 
to set labels in BatchJobService via AdGroupCriterionLabelOperation 
<https://developers.google.com/adwords/api/docs/reference/v201809/AdGroupCriterionService.AdGroupCriterionLabelOperation>
.

*Note*: We are running an annual developer feedback survey. Please take 
opportunity to leave feedback 
<https://www.google.com/url?q=https%3A%2F%2Fgoogle.qualtrics.com%2Fjfe%2Fform%2FSV_8AJmKtdyZLWVWrb&sa=D&sntz=1&usg=AFQjCNEvRgTEW8m96OdR4nS8-UASi0ek7Q>
 on 
how we can make managing campaigns at scale even easier.

Thanks,
Vincent
AdWords API Team

On Wednesday, October 31, 2018 at 9:34:08 AM UTC+8, s...@feedonomics.com 
wrote:
>
> $label_id = TempIdGenerator::Generate();
> $keyword_label = new TextLabel();
> $keyword_label->setId($label_id);
> $keyword_label->setName($label_text);
> $keyword_label->setAttribute('test');
>
> $label_operation = new LabelOperation(); // Label operation should not be 
> included in the BatchJobService
> $label_operation->setOperand($keyword_label);
> $label_operation->setOperator('ADD');
>
> $adwords_services = new AdWordsServices();
> $label_service = $adwords_services->get($session, LabelService::class);
> $result = $label_service->mutate(array($label_operation));
>
> $adgroup_criterion = new AdGroupCriterion();
> $adgroup_criterion->setLabels(array(new AdGroupCriterionLabel($adgroup_id, 
> $keyword_id, $label_id)));
>
> $operation = new AdGroupCriterionLabelOperation();
> $operation->setOperand($adgroup_criterion);
> $operation->setOperator('ADD');
>
> return $operation;
>
> The above code is what ended up working for us, but we are still getting 
> these errors:
>
> This XML file does not appear to have any style information associated 
> with it. The document tree is shown below.
> <mutateResponse xmlns="https://adwords.google.com/api/adwords/cm/v201806";>
> <rval>
> <errorList>
> <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="
> RequiredError">
> <fieldPath>operations[0].operand.adGroupId</fieldPath>
> <fieldPathElements>
> <field>operations</field>
> <index>0</index>
> </fieldPathElements>
> <fieldPathElements>
> <field>operand</field>
> </fieldPathElements>
> <fieldPathElements>
> <field>adGroupId</field>
> </fieldPathElements>
> <trigger/>
> <errorString>RequiredError.REQUIRED</errorString>
> <ApiError.Type>RequiredError</ApiError.Type>
> <reason>REQUIRED</reason>
> </errors>
> <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="
> RequiredError">
> <fieldPath>operations[0].operand.criterionId</fieldPath>
> <fieldPathElements>
> <field>operations</field>
> <index>0</index>
> </fieldPathElements>
> <fieldPathElements>
> <field>operand</field>
> </fieldPathElements>
> <fieldPathElements>
> <field>criterionId</field>
> </fieldPathElements>
> <trigger/>
> <errorString>RequiredError.REQUIRED</errorString>
> <ApiError.Type>RequiredError</ApiError.Type>
> <reason>REQUIRED</reason>
> </errors>
> <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="
> RequiredError">
> <fieldPath>operations[0].operand.labelId</fieldPath>
> <fieldPathElements>
> <field>operations</field>
> <index>0</index>
> </fieldPathElements>
> <fieldPathElements>
> <field>operand</field>
> </fieldPathElements>
> <fieldPathElements>
> <field>labelId</field>
> </fieldPathElements>
> <trigger/>
> <errorString>RequiredError.REQUIRED</errorString>
> <ApiError.Type>RequiredError</ApiError.Type>
> <reason>REQUIRED</reason>
> </errors>
> <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="
> RequiredError">
> <fieldPath>operations[0].operand.labelId</fieldPath>
> <fieldPathElements>
> <field>operations</field>
> <index>0</index>
> </fieldPathElements>
> <fieldPathElements>
> <field>operand</field>
> </fieldPathElements>
> <fieldPathElements>
> <field>labelId</field>
> </fieldPathElements>
> <trigger/>
> <errorString>RequiredError.REQUIRED</errorString>
> <ApiError.Type>RequiredError</ApiError.Type>
> <reason>REQUIRED</reason>
> </errors>
> <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="
> RequiredError">
> <fieldPath>operations[0].operand.criterionId</fieldPath>
> <fieldPathElements>
> <field>operations</field>
> <index>0</index>
> </fieldPathElements>
> <fieldPathElements>
> <field>operand</field>
> </fieldPathElements>
> <fieldPathElements>
> <field>criterionId</field>
> </fieldPathElements>
> <trigger/>
> <errorString>RequiredError.REQUIRED</errorString>
> <ApiError.Type>RequiredError</ApiError.Type>
> <reason>REQUIRED</reason>
> </errors>
> <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="
> RequiredError">
> <fieldPath>operations[0].operand.adGroupId</fieldPath>
> <fieldPathElements>
> <field>operations</field>
> <index>0</index>
> </fieldPathElements>
> <fieldPathElements>
> <field>operand</field>
> </fieldPathElements>
> <fieldPathElements>
> <field>adGroupId</field>
> </fieldPathElements>
> <trigger/>
> <errorString>RequiredError.REQUIRED</errorString>
> <ApiError.Type>RequiredError</ApiError.Type>
> <reason>REQUIRED</reason>
> </errors>
> </errorList>
> <index>0</index>
> </rval>
> </mutateResponse>
>
> Any idea how we can fix these errors? The label is getting added to the 
> keyword now.
>
> Thanks!
>
> On Tuesday, October 30, 2018 at 4:46:19 PM UTC-7, Vincent Racaza (AdWords 
> API Team) wrote:
>>
>> Hi,
>>
>> Before you can associate the label to your ad group via 
>> AdGroupCriterionService 
>> <https://developers.google.com/adwords/api/docs/reference/v201809/AdGroupCriterionService>,
>>  
>> you need to create a label 
>> <https://developers.google.com/adwords/api/docs/reference/v201809/LabelService.Label>
>>  first 
>> with its text/name 
>> <https://developers.google.com/adwords/api/docs/reference/v201809/LabelService.Label#name>
>>  via LabelService.mutate() 
>> <https://developers.google.com/adwords/api/docs/reference/v201809/LabelService#mutate>
>> .
>>
>> Let me know if you have further clarifications.
>>
>> Thanks,
>> Vincent
>> AdWords API Team
>>
>> On Wednesday, October 31, 2018 at 5:35:57 AM UTC+8, s...@feedonomics.com 
>> wrote:
>>>
>>> Hi Shwetha,
>>>
>>> We are trying to do the same, but how do we set the label text for 
>>> AdGroupCriterionLabel? I don't see a set function for label text.
>>>
>>> Thanks!
>>>
>>> On Thursday, June 16, 2016 at 9:25:35 AM UTC-7, Shwetha Vastrad (AdWords 
>>> API Team) wrote:
>>>>
>>>> Hi,
>>>>
>>>> To add labels to your keywords, you would need to create 
>>>> AdGroupCriterionLabel 
>>>> <https://developers.google.com/adwords/api/docs/reference/v201605/AdGroupCriterionService.AdGroupCriterionLabel>
>>>>  which 
>>>> contains:
>>>>
>>>>    - labelId - ID of the label.
>>>>    - adGroupId - ID of the AdGroup containing the keyword.
>>>>    - criterionId - ID of the keyword.
>>>>
>>>> Once you have created these objects, you need to use the 
>>>> AdGroupCriterionService.mutateLabel 
>>>> <https://developers.google.com/adwords/api/docs/reference/v201605/AdGroupCriterionService.html#mutateLabel>
>>>>  with 
>>>> ADD operator to associate an existing Label 
>>>> <https://developers.google.com/adwords/api/docs/reference/v201605/AdGroupCriterionService.Label.html>
>>>>  to 
>>>> an existing AdGroupCriterion 
>>>> <https://developers.google.com/adwords/api/docs/reference/v201605/AdGroupCriterionService.AdGroupCriterion.html>
>>>> .
>>>>
>>>> Regards,
>>>> Shwetha, AdWords API Team.
>>>>
>>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
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/409ba994-1d90-40c1-b2d1-d8d29f8f1653%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • ... sam
    • ... 'Vincent Racaza (AdWords API Team)' via AdWords API and Google Ads API Forum
      • ... sam
        • ... 'Vincent Racaza (AdWords API Team)' via AdWords API and Google Ads API Forum
          • ... sam
            • ... 'Sreelakshmi Sasidharan (AdWords API Team)' via AdWords API and Google Ads API Forum
    • ... bruno . yano
      • ... 'Sreelakshmi Sasidharan (AdWords API Team)' via AdWords API and Google Ads API Forum

Reply via email to