Hi Alan,

That's right! The outcome is the same.
I'm using MutateJobServive,mutate and the operations are a list of the ads 
created. My previous snippet is the creation of such a list.
So it's a regular TextAd creation operation, with an additional key in the 
dictionary.
Relevant documentation: type AdGroupAd (v201409) 
<https://developers.google.com/adwords/api/docs/reference/v201409/MutateJobService.AdGroupAd>
For the label field it states: This field is read only and will be ignored 
when sent to the API for the following Operator 
<https://developers.google.com/adwords/api/docs/reference/v201409/MutateJobService.Operator.html>s:
 
REMOVE and SET.
What we are doing is an ADD operation because we want to assign the label 
at the time of creation, so there's no conflict there.

Possible issues that might make your request fail:

   1. Old API version (I guess not as the link you sent is from v201409)
   2. Wrong label structure. What I'm sending in the labels field is a list 
   of dictionaries, just with the labelId. (... 'labels': [{'id': 
   Label_id}], ...)
   3. Wrong method. MutateJobServive,mutate or AdGroupAdService.mutate 
   should work fine as well. Just don't use  AdGroupAdService.mutateLabel, 
   because as you've realised, that's for existing ads.


Let me know if you get it working.
Cheers!

On Thursday, 23 October 2014 06:14:40 UTC-3, Alan Coleman wrote:
>
> Hi Martin,
>
> Sorry to keep going on about this but I'm confused about how you're 
> getting this to work.
>
> Can I confirm that I'm trying to achieve the same outcome as yourself?
>
>    1.  A Label has been created previously and I have the ID
>    2. I want to create a TextAd and assign the above label whilst 
>    creating the TextAd
>
> I've tried two services:
>
>    1. AdGroupAdService
>    2. MutateJobService
>    
> With variations on the following code:
>
> $textAd->displayUrl = $textDisplayUrl;
> $textAd->url = $textUrl;
> $textAd->labels = $labelid;
>
> This is returning an Undefined index error.
>
> The documentation clearly states that the services are read only and that 
> AdGroupAdService.mutateLabel 
> <https://developers.google.com/adwords/api/docs/reference/v201409/AdGroupAdService.html#mutateLabel>
>  should 
> be used to add an *existing Label* to an *existing AdGroupAd.*
> I'd really like to be able to add an existing label when creating a 
> TextAd, I'm just confused about how you're achieving this.
>
> Many thanks
>
>
> On Wednesday, October 8, 2014 11:18:46 PM UTC+1, Martin wrote:
>>
>> Hi all!
>> I disagree with the accepted solution. I am currently assigning labels to 
>> Text Ads in a single operation at the time of creation. Below is the 
>> relevant snippet from my python code. I'm using the MutateJobService and it 
>> works just fine.
>>                 adgroup_ad_operations.append({
>>                     'xsi_type': 'AdGroupAdOperation',
>>                     'operator': 'ADD',
>>                     'operand': {
>>                         'xsi_type': 'AdGroupAd',
>>                         'adGroupId': adGroupId,
>>                         'ad': textad,
>>                         'status': 'ENABLED',
>>                         'labels': [{'id': Label_id}],
>>                     },
>>                 })
>>
>> I hope this helps. :)
>> Cheers!
>> Martin
>>
>>
>> On Wednesday, 8 October 2014 05:18:07 UTC-3, Alan Coleman wrote:
>>>
>>> Thanks for getting back to me Michael! :-)
>>>
>>> On Friday, October 3, 2014 6:19:06 PM UTC+1, Michael Cloonan (AdWords 
>>> API Team) wrote:
>>>>
>>>> Hello,
>>>>
>>>> You are correct; you must create the TextAd first, and then in a 
>>>> separate operation you may assign a label to it. There is no way to assign 
>>>> a label to the TextAd at the time of creation.
>>>>
>>>> Regards,
>>>> Mike, AdWords API Team
>>>>
>>>> On Friday, October 3, 2014 6:37:01 AM UTC-4, Alan Coleman wrote:
>>>>>
>>>>> Hello everyone,
>>>>>
>>>>> I'd like to be able to add a *label* to a *TextAd *when creating the 
>>>>> TextAd.
>>>>>
>>>>> I'm creating the TextAd using AdGroupAdOperation 
>>>>> <https://developers.google.com/adwords/api/docs/reference/v201406/AdGroupAdService.AdGroupAdOperation>
>>>>> .
>>>>>
>>>>> If I want to use AdGroupAdLabelOperation 
>>>>> <https://developers.google.com/adwords/api/docs/reference/v201406/AdGroupAdService.AdGroupAdLabelOperation>
>>>>>  
>>>>> to add a label then I first have to return the TextAd id from the 
>>>>> AdGroupAdOperation 
>>>>> <https://developers.google.com/adwords/api/docs/reference/v201406/AdGroupAdService.AdGroupAdOperation>
>>>>> .
>>>>>
>>>>> So am I right in saying that to add a *label* to a *TextAd *I have to 
>>>>> create both using separate operations then add the Label to the TextAd?
>>>>>
>>>>> I think I may have answered my own question here, but any suggestions 
>>>>> would be helpful.
>>>>> Many thanks
>>>>>
>>>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 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 http://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/6b24f446-3c84-4189-a169-b644aab63a11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to