# How to check for URL conflicts without creating a entity?

**URL:** <https://forum.litium.com/t/how-to-check-for-url-conflicts-without-creating-a-entity/383>\
**Category:** Questions\
**Created:** [November 25, 2018, 6:05am UTC](https://forum.litium.com/t/how-to-check-for-url-conflicts-without-creating-a-entity/383 "2018-11-25T06:05:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zsrdos](https://avatars.discourse-cdn.com/v4/letter/z/74df32/32.png) [@Zsrdos](https://forum.litium.com/u/Zsrdos)\
**Post date:** [November 25, 2018, 6:05am UTC](https://forum.litium.com/t/how-to-check-for-url-conflicts-without-creating-a-entity/383/1 "2018-11-25T06:05:47Z")

</div>

Hi how do I from code perform a URL check to check that a url is not in use / get an alternative url suggestion if it is in use? (I am dynamically creating pages and categorys)

Litium version: 7

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [November 26, 2018, 10:13am UTC](https://forum.litium.com/t/how-to-check-for-url-conflicts-without-creating-a-entity/383/2 "2018-11-26T10:13:49Z")

</div>

I think you can use UrlHelper for that cause.

---

<div class="post-metadata">

**Author:** ![magnus.bolling](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/magnus.bolling/32/222_2.png) [@magnus.bolling](https://forum.litium.com/u/magnus.bolling)\
**Post date:** [April 1, 2019, 9:09am UTC](https://forum.litium.com/t/how-to-check-for-url-conflicts-without-creating-a-entity/383/3 "2019-04-01T09:09:48Z")

</div>

Any updates/examples to this?  
I would like to check if a category already exists with the URL I’m trying to create dynamically with CategoryService.

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [April 1, 2019, 9:18am UTC](https://forum.litium.com/t/how-to-check-for-url-conflicts-without-creating-a-entity/383/4 "2019-04-01T09:18:03Z")

</div>

Inject ISuggetionService and then use Suggest method.

---

<div class="post-metadata">

**Author:** ![magnus.bolling](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/magnus.bolling/32/222_2.png) [@magnus.bolling](https://forum.litium.com/u/magnus.bolling)\
**Post date:** [April 1, 2019, 9:57am UTC](https://forum.litium.com/t/how-to-check-for-url-conflicts-without-creating-a-entity/383/5 "2019-04-01T09:57:33Z")

</div>

Tried that but gives me the following error:  
“Localization[sv-SE].Url: ‘The URL is occupied by a sibling category.’.”

Seems like it only suggests an url, not checking if there’s already an existing category with that suggestion.

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [April 1, 2019, 10:14am UTC](https://forum.litium.com/t/how-to-check-for-url-conflicts-without-creating-a-entity/383/6 "2019-04-01T10:14:35Z")

</div>

It has to give you a non existing url otherwise it might be a bug.

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [April 1, 2019, 3:18pm UTC](https://forum.litium.com/t/how-to-check-for-url-conflicts-without-creating-a-entity/383/7 "2019-04-01T15:18:43Z")

</div>

`ISuggetionService` is **not** validating that the url-segment is in use, it is suggesting an sanitized url-segment. To be able to validate if the url-segment can be used also other parameters need to be included like if the url is for a page, category, base product or variant and if it is a page or category it also need to know the parent object.

If you only want to do a validation before saving you can inject the `ValidationService` and use the validate method on that to get an answer if the entity have any invalid data, it is this method that the create/update methods are using.
