Label creation with Python

198 views
Skip to first unread message

odo...@gmail.com

unread,
Oct 31, 2014, 12:56:58 PM10/31/14
to adwor...@googlegroups.com
I tried to add a Label to a campaign. In order to do that, I need the ID of the Label so I tried to create the Label before.

operation = [
 {
     'operator': 'ADD',
     'operand': {
         'name': 'New label',
         'status': 'ENABLED',
         # 'xsi_type': '???????',
     }
 }
]
label_service.mutate(operation)

They ask me a Type.Label but there is nowhere I can find which type I can use ... Then I get this error.

INVALID_LABEL_TYPEInvalid Label type. A specific type of Label is required.
Thank you for your answer,

Martin

Josh Radcliff (AdWords API Team)

unread,
Oct 31, 2014, 5:22:52 PM10/31/14
to adwor...@googlegroups.com
Hi Martin,

The type Label is an abstract type -- you'll want to create/specify a TextLabel when creating a new label.

Cheers,
Josh, AdWords API Team

Mark Prentice

unread,
Nov 20, 2014, 6:47:06 AM11/20/14
to adwor...@googlegroups.com
I had this same problem too...would be nice if this was made clear in the documentation, or possibly a slightly more helpful error? I was trying to work out what Label.Type they were wanting, especially given that in the documentation it didn't list this as required.

It was most confusing.

Rocky Jaiswal

unread,
Nov 21, 2014, 6:18:45 AM11/21/14
to adwor...@googlegroups.com
We have something like this in Ruby, maybe it helps you -

     response = label_service.mutate([{operator: 'ADD',
                                                       operand: {xsi_type: 'TextLabel',
                                                       name: label_text}
                                       }])
      response[:value].first

Josh Radcliff (AdWords API Team)

unread,
Nov 21, 2014, 11:22:42 AM11/21/14
to adwor...@googlegroups.com
You also may want to check out the Labels Guide, which provides an overview of using labels and also mentions that you should use TextLabel.

Cheers,
Josh, AdWords API Team
Reply all
Reply to author
Forward
0 new messages