Last active
May 29, 2021 10:49
-
-
Save ktskumar/7d44e68bfe02a5998629ebab45c7d9b4 to your computer and use it in GitHub Desktop.
Access Microsoft Power Platform Environments through 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
//Try this code in Microsoft Power Automate Home page | |
function getRequest(url) { | |
var request = new XMLHttpRequest(); | |
return new Promise(function(resolve, reject) { | |
request.onreadystatechange = function() { | |
if (request.readyState !== 4) return; | |
if (request.status >= 200 && request.status < 300) { | |
resolve(request); | |
} else { | |
reject({ | |
status: request.status, | |
statusText: request.statusText | |
}); | |
} | |
}; | |
request.open('GET', url, true); | |
request.setRequestHeader("Content-Type", "application/json;charset=utf-8"); | |
request.setRequestHeader("ACCEPT", "application/json; text/plain, */*"); | |
request.setRequestHeader("AUTHORIZATION", "Bearer " + window.sessionInfo.userInfo.accessToken); | |
request.setRequestHeader("ODATA-VERSION", "4.0"); | |
request.send(); | |
}); | |
} | |
var environments; | |
getRequest("https://india.api.flow.microsoft.com/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01").then(function(resp) { | |
environments = JSON.parse(resp.response).value; | |
environments.forEach(function(e) { | |
console.log("Environment Name: " + e.name) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment