cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
leolsdn
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

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
JohnAageAnderse
Memorable Member
Memorable Member

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 

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 ?

 

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

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. 

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

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

 

Thanks. 

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

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,730)