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

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

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

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

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

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

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

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

 

Thanks. 

Highlighted

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

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Users online (14,043)