cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Verify is a SharePoint site already exists

Hello,

 

How can I verify that a SharePoint URL already exists within a site collection?

Eg. I'm in a site collection, and I want to create a new subsite. How can I verify that the subsite is not already there using PowerAutomate?

 

Thanks. 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Verify is a SharePoint site already exists

Hello @leolsdn 

When you use the (+) symbol between actions, then you get the option to add a parallel branch

Flow.Parallel.How to.jpg

Kind regards, John

View solution in original post

8 REPLIES 8
Highlighted
Super User II
Super User II

Re: Verify is a SharePoint site already exists

Hello @leolsdn 

You can use the Send an HTTP request to SharePoint action using this URL "https://<your  sharepoint site>/_api/web/webinfos" and it will return the subsites as an XML response.

Try it out 🙂

Kind regards, John 

Highlighted
Helper I
Helper I

Re: Verify is a SharePoint site already exists

Hi John,

 

This is what I did:

 

1.png

2.png

 

The issue is that the condition's "answer" is always "False", although the URL is there.

 

 

3.png

 

4.png

Any idea how can I get "true" when the URL exists and "false" when it doesn't ?

 

Highlighted
Super User II
Super User II

Re: Verify is a SharePoint site already exists

Hello @leolsdn 

The result from the call is an object, so Contains will not work. Convert the Body to a string using the expression:

string(outputs('Send_an_HTTP_request_to_SharePoint')?['body'])
instead of the dynamic content
Flow.Condition.String HTTP body.jpg
Edit: Be careful with case sensitivity!
Kind regards, John
Highlighted
Helper I
Helper I

Re: Verify is a SharePoint site already exists

Hi @JohnAageAnderse 

 

You suggestion works!!! Thanks a lot!

Now the problem is that if the URL doesn't exist, I won't get a "False" within the condition.

The Flow will stop with a NOT Found error and I never reach the condition step.

 

5.png

 

6.png

 

Could you suggest another way to check is a SPWeb exists and if not create a new one?

 

Thanks. 

Highlighted
Super User II
Super User II

Re: Verify is a SharePoint site already exists

Hello @leolsdn 

Good that it works 🙂 You are correct that the flow will fail at the HTTP action, if the URL does not exist.

You can replace your Condition action with a parallel branching, where the two parallel branches each can handle the success or the failure of the HTTP action.

Flow.Parallel.Success.Failure handling.jpg

Configure each branch run after settings

Flow.Parallel.Success.Failure handling.Run after.jpg

One to run upon success, one to run on failure.

Hope the above helps you on the way to a solution 🙂

Kind regards, John

Highlighted
Helper I
Helper I

Re: Verify is a SharePoint site already exists

Thanks @JohnAageAnderse : how do I add the parallel branching after "Send an HTTP request to SharePoint" ?

 

Thanks. 

Highlighted
Super User II
Super User II

Re: Verify is a SharePoint site already exists

Hello @leolsdn 

When you use the (+) symbol between actions, then you get the option to add a parallel branch

Flow.Parallel.How to.jpg

Kind regards, John

View solution in original post

Highlighted
Helper I
Helper I

Re: Verify is a SharePoint site already exists

Hi @JohnAageAnderse 

 

Thanks a million!!! It works great!!!

 

I'm documenting this if some other people try to do similar things:

 

Here is the flow:

 

A.png

B.png

In case the site exists:

 

OK1.png

 

OK2.png

 

And in case the site doesn't exist:

 

NOK1.png

 

NOK2.png

Helpful resources

Announcements
secondImage

August 2020 CYST Winners!

Check out the winners of the recent 'Can You Solve These?' community challenge!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Users online (4,179)