Label update returns DUPLICATE_NAME

48 views
Skip to first unread message

Kostas Kougios

unread,
Oct 5, 2020, 11:26:24 AM10/5/20
to AdWords API and Google Ads API Forum

Hi,

I am having this issue where I can't update any labels. The update doesn't change the label name.

My code is pretty standard I think (scala):

val g = Label.newBuilder
.setName(StringValue.of("Keyword_Coverage_v4.0_Native"))
.setStatus(LabelStatus.valueOf("ENABLED"))
.setResourceName("customers/$ACC/labels/$LABEL_ID")
.build
val fields = FieldMasks.allSetFieldsOf(g)
val op=LabelOperation.newBuilder
.setUpdate(g)
.setUpdateMask(fields)
.build
val client = clientProvider.googleAdsVersion.createLabelServiceClient
client.mutateLabels(account.id.toString,Seq(op).asJava)

Keyword_Coverage_v4.0_Native exists already but I am getting this error:

[error_code {
  label_error: DUPLICATE_NAME
}
message: "Label names must be unique."
trigger {
  string_value: "Keyword_Coverage_v4.0"
}
location {
  field_path_elements {
    field_name: "operations"
    index {
    }
  }
  field_path_elements {
    field_name: "create"
  }
  field_path_elements {
    field_name: "name"
  }
}
,]

Any ideas why?

Thanks

Google Ads API Forum Advisor Prod

unread,
Oct 6, 2020, 3:12:50 AM10/6/20
to adwor...@googlegroups.com
Hi Kostas,

The error you are encountering indicates that the label you are trying to use in your UPDATE already exists. I would recommend that you perform a GetLabelRequest initially, to validate whether the name you will be using already exists, before using it in an UPDATE or CREATE request.

If it already exists, you would need to use a different name for the said label. Let me know if this helps.

Thanks,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q25ZEgo:ref

Kostas Kougios

unread,
Oct 6, 2020, 5:56:33 AM10/6/20
to AdWords API and Google Ads API Forum
The op I did was for an

field_path_elements {
    field_name: "update"
  }
but it stopped happening since yesterday so I can't reproduce it now. What I tried is to retrieve an existing label and just update it without changing anything. That failed with a DUPLICATE_NAME.

If I manage to reproduce I will post again

Kostas Kougios

unread,
Oct 6, 2020, 9:20:46 AM10/6/20
to AdWords API and Google Ads API Forum
Ok it happened again, during an update. The update doesn't change the label name:

error_code {
  label_error: DUPLICATE_NAME
}
message: "Label names must be unique."
trigger {
  string_value: "Keyword_Coverage_v4.0_Native"

}
location {
  field_path_elements {
    field_name: "operations"
    index {
    }
  }
  field_path_elements {
    field_name: "update"
  }
  field_path_elements {
    field_name: "name"
  }
}

So my label is already there when I run the update. The update doesn't change the label.

+-----------------------------------+-------+---------------------------------------+
|name                               |status |resource                               |
+-----------------------------------+-------+---------------------------------------+
|Keyword_Coverage_v4.0_Native       |ENABLED|customers/###/labels/###

I can send customer id and label id in a private msg if required.

Kostas Kougios

unread,
Oct 6, 2020, 9:44:12 AM10/6/20
to AdWords API and Google Ads API Forum
and managed to recreate with plain java api code (in scala, v9.0.0 of the java api dep, v5 of the api):

val resource = "customers/###/labels/###" // note please ask for ids, it may be occurring only in certain accounts

import com.google.ads.googleads.v5.enums.LabelStatusEnum.LabelStatus
import com.google.ads.googleads.v5.resources.Label
import com.google.ads.googleads.v5.services.LabelOperation

val l = Label.newBuilder
.setName(StringValue.of("Keyword_Coverage_v4.0_Native"))
.setStatus(LabelStatus.ENABLED)
.setResourceName(resource)
.build

val op=LabelOperation.newBuilder
.setUpdate(l)
.setUpdateMask(FieldMasks.allSetFieldsOf(l))

.build

val client = clientProvider.googleAdsVersion.createLabelServiceClient

try {
client.mutateLabels(account.id.toString, Seq(op).asJava)
} finally client.close()



When I actually changed the label name, the update worked:

.setName(StringValue.of("Keyword_Coverage_v4.0_Native-UPD"))

and when I changed the name back, it now works fine:

.setName(StringValue.of("Keyword_Coverage_v4.0_Native"))

(run twice, the update now succeeds!)

Google Ads API Forum Advisor Prod

unread,
Oct 6, 2020, 3:19:18 PM10/6/20
to adwor...@googlegroups.com
Hello,

Please share the request and response for the API calls that fail for these updates. Do so using reply privately to author.

Regards,
Anthony
Google Ads API Team

Google Logo
Anthony
Google Ads API Team
 


ref:_00D1U1174p._5004Q25ZEgo:ref

Kostas Kougios

unread,
Oct 8, 2020, 4:46:42 AM10/8/20
to AdWords API and Google Ads API Forum
ok thanks, I've send the email

Google Ads API Forum Advisor Prod

unread,
Oct 8, 2020, 3:24:20 PM10/8/20
to adwor...@googlegroups.com
Hello,

Ok thanks. We will follow up on that there.
Reply all
Reply to author
Forward
0 new messages