SharePoint / SharePoint Online – Calling REST Service from SharePoint Designer Workflow
Today, we are going to discuss how REST service is called in from SharePoint Designer Workflow. For demonstration purpose I am accessing my Login Name through REST API from Site Users Information List.
Let’s get started!!
- Should have SharePoint Designer installed.
- Should know how to create list workflow.
Follow these steps:
- Create List Workflow.
- In the Stage 1 (You can rename Stage 1 to any meaningful name you want), add an action Build Dictionary or just click on orange bar and type build and press ENTER. It will add Build Dictionary See following figure.
- Click on “this” in the action to open Build A Dictionary and click Add.
- We are going to add two request headers
- Name: Accept
- Name: content-type
Request headers are required to send request to web server containing details of what the browser wants and will be ready to accept back from server. Do not make any mistake while writing value for above two request headers. A single mistake and you will not get output. Click Ok.
- Create output variable. Name it whatever you want. In this case RequestHeader.
- Now add action Call … Http web service
- Click on “this”. It opens Call HTTP Web Service window as follows. Click on three dots next to the text field provided below Enter the HTTP web service URL.
- It opens String builder dialog. Click on Add or change lookup. Next dialog will be opened is Lookup for String. Select Data Source as Workflow Context and Field from source as Current site URL and finally click Ok.
For reference please have a look to following figure.
- Complete url as shown in the following figure. i.e. “SiteUrl/_api/web/siteusers/getbyid(10)” here I am applying filter by using getbyid(10) where 10 is my user id.
- Right click on Call action and open Select proper variable name against their Parameters. Refer following figure. And click Ok.
- If you want to check response code value, log response code variable using Log to History List action
- Add Get Click Item by name or path and then click three dots next to it. In the string builder type d/LoginName. Select response content, which is collection of data requested by you. Select or create output variable.
- Log output variable. Follow the same procedure as we did in step 8 or simply click “fx” symbol. Just this time select Workflow Variables and Parameters as Data Source and select your variable you created as output variable, in this case Output. Click Ok.
- In transition to stage select End of Workflow.
- Save and Publish.
- Here I am starting workflow manually. You can choose any option among three options available.
- Check the output below.
- Highlighted by yellow marker is our output (Login name).
This is how REST service is called from SharePoint Designer Workflow.
Thanks for reading 🙂
Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more. If you have any suggestion / feedback / doubt, you are most welcome.
Stay tuned on Knowledge-Junction, will come up with more such articles