Url import exception, value is not unique

Hi!

When we are importing new variants and we sometimes get url error:

Article import error: [CreateArticle] Validation error for Variant(SystemId: cc5f755c-df3a-460a-b96f-765dabd1c01f, Id: 02116090102), Localization[nb-NO].Url: ‘Value is not unique.’, Localization[en-US].Url: ‘Value is not unique.’, Localization[sv-SE].Url: ‘Value is not unique.’ and Localization[de-DE].Url: ‘Value is not unique.’

We are using the ISuggestionService to avoid this:

string url = urlSuggestions.Suggest(language.CultureInfo, suggestFrom);
_variant.Fields.AddOrUpdateValue("_url", language.CultureInfo, url);                            

Shouldn’t this guarantee that we get an unique url?

If not, how can we make sure the url is unique before saving the variant?

/Kristoffer

Litium version: 6.3

Suggest does check if the url is already taken, it only formats the provided string to a valid url.

An easy solution is to catch the specific error and keep trying to save with a suffix on the url (“url_1”, “url_2”).

Also check: How to check for URL conflicts without creating a entity?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.