Power Automate: How to create SharePoint Site Collection

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello friends welcome back to our Channel DS Tech mirror in today's video we will see how we can create SharePoint site collection automatically using power automate so let's directly move to our Office 365 so over here what I will do I have created one list called project site in this list I will add my SharePoint site title and description and I will use this list as a trigger for my power automate that means whenever I will add any item in this list my power automate will trigger and it should create the site collection automatically and over here this is my Microsoft power automate here I am going to create my power automate so let's get started here I will click on create and I will select automated cloudflow and from here let me give the flow name as create site collection and I will append it with my channel name the astick mirror so this will become my flow name and I from here I will select my trigger when an item is created or modified and I will select cricket so this is my flow over here here I will try to replicate all the errors which you might you know face if you are creating this flow for the first time we will try to fix those errors and then let's see how we will create our flow okay from here I have to select my site address I will do that my site address is POC site then my list name my list name is Project sites so this is done as a Next Step so the important step over here is to create the site collection automatically I have to use an action called send an HTTP request to share points so let me select that and then HTTP request because using this rest API we are going to create this site collection so this is done now the site address site address again I will use the same my POC site method would be post and now the URI and other things now you can get this URI which will create your site collection from Microsoft documents here you can find this link in your description box of this video as well from here if you will scroll down you can see the base URL for the rest command is underscore API slash SP site manager so I will use the same this endpoint is going to create my site collection and I will paste it over here underscore API slash SD site managers now I have to paste the body over here all the in the body I will add all the you know metadata required to create this site collection that is the title URL site type whether it is a team site or communication site language so all these things I am gonna add in this body parameter and over here I will add the headers so my first parameter would be accept and value would be application slash Json I will you know copy it from this notepad I have the value available just in the interest of the time so I will paste it over here I'll say accept as let me go to this mode and here let me paste it so my accept header will have the value of application slash Json or data none I do not want any metadata and let me go to the next one that is the content type again application slash Json or data this would be my another one the second is the content type both the both the headers will have the same value first address the accept and another one is the content type let me put one comma to have some uh to have the validation now let's go back to key value node so over here so this is one of the shortcuts which you can use if you have the address ready made with you now I'll go to this body parameter in the body parameter what I will do I'm gonna create one Json object say request object and that I will add all the properties so that is ready with me over here what I will do I will copy it from here and then I'm gonna paste it here and then I will explain you each and every property so this is my uh body object but what I will do let me remove the values that I'm gonna add and all these things I will leave as it is so over here what you can see even if I copy this complete object in a notepad and I can explain you over here and you can find find this complete object in the description box below you can directly use it if you are replicating this Hands-On so over here you can see this is the Json object request inside this I have first property called URL URL of the site we need then we need Title description we need LCD is the language value will remain one zero double three then web template whether you are creating a team site or a communication site and the owner of that particular site so these mandatory data you need also you can get some understanding of all these things from this particular link create modern sites this is also in the description box below you can see communication site this is the value if you are creating a team site non-group Associated team site this is the particular value and over here also this is the uh you know request object present over here you can make use of it from here as well or from the description box below so let's go and add the value over here so what I will do in the request URI that is in the URL I will get it from my SharePoint site or oh I will get it from my SharePoint list title so title will work as the URL over here so let me just dynamically add title then for the title also value will remain the same description again I will add in my SharePoint list that is Project site I will add the description LC ID as I said it is one zero three three okay and owner and web template is because I am creating a team site if you want to create a communication site you can use this template site publishing has zero so this is done over here now I'll try to save this flu and Save there is any error no so there are no errors so far so let's go ahead and try to run this flow whether this is gonna create any new site so what I'll do over here I will say first I will create one you know that's a demo test site and just for my knowledge I will mark it as to be deleted so I can delete it later on fine and I will say demo site this is done now this should trigger my power automate flow which I have created over here okay so what I will do I will go to my flows create site collection and over here let's see so this will take a few minutes to before it get triggers so over here uh this floor ran successfully and we can see status is succeeded so let's see if it has created any new site collection I'll click on this instance just see what are the values we will see okay so both these steps got executed successfully over here we can come and see let's see what is the value over here so what I will do let me go and try to add you know access this demo site a URL should be demo side test to be deleted let me try to access it from here and instead of this POC I'll use this one and okay so it does not exist so I'll go back and see what is the error through one of the errors which I could notice over here is uh with respect to this URI because if I go to this Microsoft site over here I could see they have mentioned the URL as underscore API slash SP site manager slash create so we have missed this create so what I will do I will copy this URL from here I'll go back to my flow and here yes and here I will paste this now we'll save and I will try to trigger my flow again and let's see what will happen flow flow is saving got saved successfully I will edit and I'll say demo test to be deleted let's say demo test and I will just save uh let's say demo test one to be deleted save let's see what will happen this will trigger my flow I'll go to my floors this is my flow create site collection and now my flow will get triggered so my flow got triggered it is in running status and it got failed so let's go back and see what is the error I will expand and now I've got a different error this operation is not supported for our relative URI okay we will try to fix this one now we will try to fix this error let's see what is the root cause for this error so we could see this error description that it is saying that it is not supported for a relative URL and over here our URL is the relative one uh so let's try and give the absolute URL so what I will do I will edit my flow and I will get rid of this title what I will do let me copy my this uh tenant path okay till here sides I will paste it over here under this URI and after that what I will do I will append and now I will say site URL title and wait what I'll do I'll remove get rid of this concatenation this will work as it is so what I have done I have done just copy this and you know static path of my site because this uh the domain name of my tenant will remain the same size slash then site title and this will become the complete URL and now we should get rid of our error I will save this flow and now what I will do uh again I first of all what I'll do let me try and edit this same site okay now save I've edited this list entry over here this will trigger my flow again I will go back to my flows for my flow and successfully but again it got failed I think there is some formatting issue with my site URL see not well formatted let's see what is the error okay so we have to put this side uh title inside this code let me edit my flow again very quickly I will get rid of this title and I will add this inside this codes after sides my site title should come so this is the site title so now I think this should work I'll save and let's make use of this test flow like automatically I will test it with the recently used trigger same one I will test it this will run immediately and floor and successfully let's see what is the outcome and over here you could see this and the response what we have got we have got this site ID site status is 2 that means our site got created successfully and this is the site URL so if I go ahead and you know select this URL try to access it I am able to access this newly created site which I have created using my flow if I go to the SharePoint admin Center I will refresh this active sites and I'll just you know sort this view with the latest with respect to the date created new to older and see this is the site which got created okay so now uh this is how we can create this flow I'll just quickly have a quick recap so at the top I have this trigger when an item is created or modified so we in the list we are adding a site detail inside description if you want you can make it more Dynamic you can add all the parameters in your list and one whenever you will add any entry in your list this flow will trigger and it will create the site okay so what we will do we will just test one more time so I'll create a new entry I'll say it uh final demo to be deleted I'll say best and save now mean meanwhile our flow will get triggered there is one important catch over here what if in my site title I've added some special characters for example at the rate or spaces those are not supported in my URL so I have to get rid of all these special characters so I will add that you know function or I will add that uh piece of code over here at the top so what I will do I will add one action I'll say initialize variable and here I will create one variable that variable name would be site URL type I will keep at string and value what I will do because I have to replace all these special characters so over here I will use the replace function so I will make use of the expression so here let me do one thing I'll say replace this function and what I will be replacing I'll make use of this title which I will get from my list so when an item is created or modified from here I will get the title this is my title so one the moment I'll select this title automatically this will get replaced with this Dynamic expression and over here I am saying replace this or replace from this expression what we have to replace so but now just to make you understand I will open the notepad I will copy this expression over here now I'll get rid of it from here first I will type this replace first let's see what is definition for replace over here so what I will do I will type replace put one bracket and this will give me the definition required the string that is searched for parameter two so in the text I will pass my site title that is the original string in which we have to replace so I will add site title over here the old text which I want to replace so for me all the special characters like and space percentage all the special character I will end Ampersand so I will get rid of all of them then third is the new text which I want to replace with the old one so this is the definition let's go and create this function in the notepad so this is my original string so now let's structure this replace expression this is my original expression this is my original string that is my site writer what I will do I will search for all the characters with space and replace them with no space now this will give me the new string now in this new string what I have to do again I have to replace all the at the rate character because at the rate is also a special character and replace it with no space I will close this one and similarly on the same basis I can you know replace whatever I want to replace from my site title so let's say for this particular video I have replaced at the rate spaces let's go with the percentage I do not want any percentage in the site title if there is any percentage I will get rid of it and I think that should be okay for at least for this particular video so we have take care of the spaces at the rate percentage any other character ah no okay fine this should be enough I will copy this now and I will go to my flow and I will paste it over here okay so this is fine if you click on it it will take you this expression I hope you all should understand this expression this is uh there is nothing complex just use the replace function pass your site title and pass the old string as the new string and just then it will that will become the that particular replace function will become your new string like the new site title so just put another replace function on top of that so this is done I will save my flow just to see if they should be no errors and now I will use this particular site title uh in my uh send an HTTP request to SharePoint but before that just to see you know in case we Face any error just to see what this is what this initialized variable or replace function will return I will use this compose action now inside I will go over here I will get rid of this title and I will pass site URL not over here here fine this should be done same now one more thing now before we start you know working with this replace function we triggered the site let's see now if this is ready for us final demo to be deleted what I will do just I'll go to my admin Center I will see over here see final demo to be deleted it's ready if I just select it created by today's time 18. created by my name today's date you could see time is different because this is a different time zone in my uh tenant in my Office 365 tenant so that's perfectly fine now what I will do I will add new entry over here and I will say let's we want to create a site for annual appraisal and over here I am adding one space and I'm saying for at the rate 2022 hyphen 23 for this fiscal year and I can do one more thing I will add one percentage sign just to test whether this is working for us everything is fine now I will save this flow no description is there that should not be any issue but we will see that will also you know kind of a test whether description is a mandatory one if it gets filled I'll come back and add the description over here before that I will go to my flow and we'll see its trigger we will wait for the trigger we will wait for the power automate to run okay our flow is running now let's go and see you should not face any error so our floor ends successfully uh the best you know litmus test to see whether our site is created just go to the last section and see the status should be two if side status is 2 that means your site got created successfully if your site status is one that means it is in progress if it is 3 then if it is 3 then there is some fatal error you have to fix that let's go and see the compose it got input annual appraisal 2 0 to 23 so it got rid of all the special characters you could see because if I just edit it in my input variable I have added my replace function so my replace function is working absolutely fine and also description is also not mandatory so if you do not want we can get rid of it uh this property also so guys in this uh we have checked all the possibilities if you want to make it Dynamic just make use of SharePoint list make use of replace function to get rid of all the special characters all these are few mandatory properties in this Json bot if you are mandated properties like web template owner URL your url has to be absolute so just remember this we faced one error related to that and just make sure that you type the correct URL correct rest endpoint so we made two errors in today's video one is related to this URI we miss discrete then we Mist we were using the relative URL and another one was the third one was the formatting one this I mistakenly passed this site URL outside the single quotes so I hope you will find this video useful and you will try it at your end just before closing this video what I will do let me just try to access this new site which we have used envelope appraisal again I will go to the admin Center I will refresh over here site got created if I click on it I can access this site this is the title where all the special characters and in the URL you could see a replace function has removed all the special characters so guys that's it for today's video If you like this video please like and share the video and subscribe to the channel to get notification for our upcoming videos if you have any doubts you can reach out to me through our official email ID or through YouTube comments you can also follow me on Twitter to get all the updates from The Office 365 World till our next video much love
Info
Channel: DS TechMirror
Views: 3,157
Rating: undefined out of 5
Keywords: update, sharepoint, site collection, shane young, powerapps, power apps, power automate, power automate flow, microsoft flow, sharepoint rest api tutorial, sharepoint rest api, sharepoint online rest api tutorial, create sharepoint site with power automate, create sharepoint site microsoft flow, power automate create sharepoint site collection, flow create sharepoint site, send an http request to sharepoint, send an http request to sharepoint flow, power apps create sharepoint site
Id: EV3F-G4FxU8
Channel Id: undefined
Length: 23min 28sec (1408 seconds)
Published: Sun Dec 18 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.