Upload file to SharePoint using MS Flow endpoint

In my previous article we saw how to Upload attachment to SharePoint list item using Microsoft Flow, as  a continuation will upload attachment using JavaScript(ajax) with MSFlow endpoint.

First, Open your flow and copy the endpoint url from 'HTTP request trigger'.


Append listname & itemid in the URL


Finally, Test it



Detailed steps



Trigger MSFlow to upload document using ajax


<html>
<head>
<title>Upload Attachment to SharePoint ListItem via MSFlow Trigger - Using Ajax</title>
<script src="jquery.js"></script>
</head>
<body>
<input type="file" name="" id="files">
<input type="button" value="Upload" onclick="uploadFile()">
<script>
// MS Flow HTTP Endpoint
var _url = "https://prod-13.centralindia.logic.azure.com:443/workflows/5178df155049ratsub4ab1a0bb136c75c38a2d/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=pE7ydsT-0sGAxl4Q0tmUrza-R_S7X75yADXlnowK-wA" +
"&listname=Expense List" + // You know the Drill!
"&itemid=5"; // Same here
// Trigger MSFlow Endpoint
function uploadFile() {
// Payload
var fd = new FormData();
fd.append('file', document.getElementById('files').files[0]);
$.ajax({
url: _url,
data: fd,
processData: false,
contentType: false,
type: 'POST',
success: function (data) {
alert('File Upload Successfully!');
}
});
}
</script>
</body>
</html>
Check out previous series for reference. I recommend reading the PowerApps scratch development seriesAzure Function integration with PowerApps and What is Microsoft Flow.

-Ratsub

Comments

  1. Hello, thanks for posting this. I have question here. After you have added HTTP request received trigger did you add any action like create item in sharepoint?

    ReplyDelete

Post a Comment

Enter your comments..

Popular posts from this blog

Secure When a HTTP request is received Power Automate a.k.a MS Flow

People picker Control in PowerApps

Upload attachment to SharePoint list item using Microsoft Flow

Modern page provisioning using page template

Headless-Daemon calling AAD secured API

Approval and auto escalation with time out in Microsoft Flow

Developing custom reusable components in PowerApps

Step-By-Step Azure AD App Registration

Create and configure custom connectors for PowerApps and MSFlow from AzureFunctions

HTML field & Date Time formatting in powerapps