I was recently creating a Flow when I realized that the “Create Item” and “Update Item” actions in Microsoft Flow would not allow me to set the value of a hyperlink field.
To overcome this, I used the “Send an HTTP request to SharePoint” action to create the item through a REST API.
I have used REST APIs on numerous occasions to overcome limitations of Microsoft Flow; however, I thought a quick instructional on how I did it would be useful as they can seem a little overwhelming to new users.
To begin, create a Flow and get to the step where you would normally use the “Create Item” action.
Create the next step, in the search bar type in “HTTP request,” and select “Send an HTTP request to SharePoint.”
Next, fill out all the fields on the action.
When entering the Uri, make sure to replace ‘List Name’ with the name of the list you want to create the item in. If there are any spaces in the list name, replace the spaces with %20. In the example below, you will see that my list name is “Proposals Needing Review” so I entered _api/web/lists/getbytitle('Proposals%20Needing%20Review')/items
- Headers: enter “content-type” for the key and “application/json;odata=verbose” for the value.
Your Flow will now create items using the REST API and correctly populate the hyperlink field.
If you continue building your flow, you will realize that you are unable to reference fields from the “Send HTTP request to SharePoint" step as dynamic content.
For example, if I go to update the item using the “Update Item” action and try to pass in the item ID from the “Send an HTTP request to SharePoint” step, the only dynamic content is “Body.” We do not see any of the fields that we passed into the item like Title, ID, etc.…
To access the fields, we need to parse out the fields we entered into the body of the request using the “Parse JSON” action.
To begin, run the flow. From the Flow results page, navigate to the “Send an HTTP request to SharePoint” step and expand it.
- Scroll down to the Body section and copy everything in the field.
- Paste it in a text editor to use later.
- Now go back to editing the Flow and add a new step.
- Enter “json” into the search box.
- Select “Parse JSON” from the list.
In the “Content” field select the Body output from the “Send an HTTP request to SharePoint” step.
Under the “Schema” input select “Use sample payload to generate schema.”
In the popup that appears enter all the JSON you copied from body output on the Flow results page earlier.
When you are finished select “Done.”
If we try to update the item again using the “Update Item” action, we will see that all the fields from the item are now available as dynamic content under the “Parse JSON” step.
Now if we run our flow we can see that it correctly adds the item and populates the hyperlink field.
DMC's Digital Workplace Solution Team has extensive experience implementing Microsoft Flow solutions in a wide range of industries for a wide range of customers.
Contact us today to get started on your next Microsoft Flow project.
Learn more about DMC's Microsoft Consulting Services.
Learn more about DMC's Digital Workplace Solutions team.