Created
June 6, 2021 05:17
-
-
Save ktskumar/4bdb609d96511e285c082241c1ee0c49 to your computer and use it in GitHub Desktop.
Retrieves the Flow templates associated to the SharePoint List using REST API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* **** RUN THIS SNIPPET in Browser Developer Console to see the output **** */ | |
// POST request Call | |
function RestRequest(url, params) { | |
var req = new XMLHttpRequest(); | |
return new Promise(function(resolve, reject) { | |
req.onreadystatechange = function() { | |
if (req.readyState != 4) // Loaded | |
return; | |
if (req.status >= 200 && req.status < 300) { | |
resolve(req); | |
} else { | |
reject({ | |
status: req.status, | |
statusText: req.statusText | |
}); | |
} | |
}; | |
var webBasedUrl = (_spPageContextInfo.webServerRelativeUrl + "//" + url).replace(/\/{2,}/, "/"); | |
req.open("POST", webBasedUrl, true); | |
req.setRequestHeader("Content-Type", "application/json;odata=verbose"); | |
req.setRequestHeader("ACCEPT", "application/json;odata=verbose"); | |
req.setRequestHeader("x-requestdigest", _spPageContextInfo.formDigestValue); | |
req.send(params ? JSON.stringify(params) : void 0); | |
}); | |
} | |
//Sends the post request and retrives the Flow templates associated to SharePoint | |
RestRequest("/_api/web/GetList(@a1)/SyncFlowTemplates?@a1='/sites/TeamSite/Lists/Clients'", null).then(function(resp) { | |
var output = JSON.parse(resp.response); | |
var flowtemps = JSON.parse(output.d.SynchronizationData).value; | |
for (var i = 0; i < flowtemps.length; i++) { | |
console.log('Name: ' + flowtemps[i].name + "\r\nDisplayName: " + flowtemps[i].properties.displayName + "\r\nDescription: " + flowtemps[i].properties.description + "\r\nPublishedTime: " + flowtemps[i].properties.publishedTime); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment