Using SharePoint REST APIs from Microsoft FLOW

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] nice hello you cannot really imagine how many times people ask me to create a video about REST API especially SharePoint REST API and all the time I was delaying it because I was so much into Marcel flow I guess this is the time to get into it but you really think I'm gonna go to purely SharePoint REST API and no again I want to go through flow but this time I want to show you how you can use and when you should use REST API in SharePoint from marks offload so let's look into it and I hope you will enjoy it let's start by a quick introduction to REST API the rest stands for representational state transfer I don't know what it means to you but if you are familiar with the web services rest is a different style of web service it's a communication protocol that you can use to call remote api's it's mainly used by JavaScript developers and SharePoint has a rich list of REST API so let's take a look at the SharePoint REST API library in the Microsoft web site and then I will show you how to use it if you search for the SharePoint REST API on any search engine on the top of the list you will find complete basic operations using SharePoint rest endpoints and if you click on it it's going to show you a complete list of operations you can scroll down and see every single one of them or you can click on the list of the items that you have in this article for example creating a site with rest so if I click on it it shows you a detailed description of how you can you how you can call this API and use it what if I want to go for working with lists and libraries or less than list items I click on this one and you will see again a good list of items working with the lists by using the rest and working with the list items by using rest for example if I click on it you will see how you can retrieve all the list items retrieve a specific list item retrieve items as a stream blah blah blah and I can scroll down and there is a lot more to it many of them you really don't need to use REST API so they come to the important question when do we use SharePoint rests api's the simple answer to this question is that when you're using Microsoft law you use it only when you have to so if there are actions inside flow that will do the job that you want to do you really don't need to go for the rest api it's much cleaner to do it and a lot more understandable and maintainable if you do it just by using actions out-of-the-box in Microsoft law now there are cases that Flo doesn't give you that for example you want to create a site in that case if you want to create a site probably you need to use a REST API if you want to create the site using flow so in that case you have to come to the list of REST API s and use it in this video I want to come to the question that I have been asked so many times by my students the typical question is that how can I update one single field in a list item from flow if you go through the list item action you need to provide all the fields that need to be updated while most of the time we don't even have them so typically will read the entire item get the values the values that we don't want to change we need to reassign it the values that we want to change we put the new values inside it now we want to pick one field and update that very specific field and I'm gonna use that as an example on how to use REST API to do the things inside SharePoint everything else is exactly the same things so as soon as you can do one you can do everything else still if you have any questions put it in the comments below and I will be more than happy to answer that there's the list that I created inside SharePoint there are a couple of items into it and I also added a field called count so my flow should accept ID and account and come to this list and find item related to this ID and sets the count to the number that I enter from the flow button let's see how we do it I go to flow that Microsoft comm I click on my flows and as always I want to create a floor from scratch so I give it a name update product count I select manually trigger a flow and I click on create and here as a parameters the first parameter is going to be number and I call it product ID and the second parameter again it's going to be number and this one is gonna be product count save and of course I cannot save it because the flow doesn't have an action yet so I need to add a new step and update if I go directly to SharePoint and I select SharePoint and under SharePoint I look for update an update item is added here you will see that as soon as I select the SharePoint and the list which is going to be products there's a whole set of items that I need to add here to update so of course I need to provide the ID so I have to read the item and after that I have to specify title otherwise I cannot even run this flow and then I can add the other fields so if there's not what I want to do I want to have the ID and account that I'm getting from the button and I want to go directly to that record and update it this is something that update cannot do and for that I need to use press API so I go back to the list of REST API working with the list items by using rest great let me scroll down and I guess here I have something called update create list item create list item in a folder update list item this is what we need right here it explains the signature of this trust API and I will show you how we can use it so let me go back to my flow designer let me get rid of this one I click okay add new step and I want to go again to SharePoint click on SharePoint and I look forward past it gives you sent an HTTP request to SharePoint this is exactly what I need site address I pick it up the method is going to be Oh what is the method let me go back to the process API definition and you see the method is post so I come back here and I set the method to post the URI is the URI of the method that I want to call the rest API is have URL so if you see this is the URL that is defined in the signature the entire site URL and then API this is where it starts web lists and then you need to use get by title so we specify the title of the list and then we need to specify the item so that the entire thing gives us the specific list item from specific lists that you specify so let me just copy this and go back to my flow as you can see it tells you exactly that you need to start the URL from underscore API so it kind of gives you an idea how to work with it so the list title that I want to use is going to be products let me go back to SharePoint and verify that this is the title that you have then the item ID that I have should come from the button so if I go to this side scroll down you see I have a product ID I click on it and this is going to feed the rest API called read the product ID that I need so far so good now let me go back to the definition and see what else we need there is authorization that we really don't care about it because the control itself will take care of it so if I click on this drop down here you will see that actually I'm using this connection so authentication and authorization is taken care of by the flow which makes our life a whole lot easier now we need to go back to the headers if I go back to the headers you will see there are a few headers that I need to take care of one of them is if match I pick the F match as one of the headers that I need to add here and I pass the value asterisk the other key that I have here is HTTP HTTP method I pick it up I come back here and the X and the X HTTP method value is merge teracle this is the value that we need copy and I paste it again here what else let's go back here accept and content-type so except I pick it up again another part of this header and I pick the value from here it's going to be application slash JSON and I pick the entire thing and place it here the other parameter that I have is content type I pick it up and again I paste the value for the content type here let's get back here and paste it so far so good now we get to the important part which is body let me go back here it has a little bit of complexity this is the body message let me just copy it completely and then I tell you how it works I copy it and I bring it here there are a couple of things that you need to take care of first of all this is the field name so instead of title I need to add count and the value that should go here is going to be the value that I get from trigger so I'd go back again here and I have something called a product count that I feed it to this request body the other part is the SP dot theta dot test list item this test is actually the name of that list the name of that list here is very simple it's just products so I can simply use products products and I save it but if it's a combined name like to what reward name or something like that usually the name is not as simple so in that case use the SharePoint client browser go to that object and get the static name of that object and then just put it right here in this case it's very easy because it's just one word so the internal name and the title are exactly the same thing so let me just save it and test and see how it works let me click on test I'll perform everything save and test sign in a successful continue now the product ID ID go back inside SharePoint I want to update product ID five so I come back here I put five here and the count that I want to add is going to be hundred I click on run now done let's see the result they are both happy and let's go to SharePoint and see if it is updated I'm gonna fresh the page and there we go let's do another one so this time I will go for product number 8 and I want to set the count to 140 I click on run now again done and if I go back here refresh and I have 140 that was all about it you can use the REST API but don't overdo it as I told you you use it only when you really have to there are lots of actions in Microsoft load that will do all the jobs that you need to do there are a few things that those actions will not provide that when you really need those you go to rest api's at the end I have started and of course I'm not gonna tell you the title but working with the rest api is one of our chapters can you guess the course title put it in the comment I'm not gonna say yes or no but we wait and see the course title when it is out thank you for watching [Music]
Info
Channel: Alireza Aliabadi
Views: 15,040
Rating: 4.8904109 out of 5
Keywords: Microsoft Flow, SharePoint Online, REST API, SharePoint REST API, SharePoint Online REST API, Update single sharepoint field from Microsoft Flow, Update SharePoint list item
Id: l2JGbiNqGgc
Channel Id: undefined
Length: 15min 0sec (900 seconds)
Published: Thu Sep 12 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.