I am trying to retrieve the user profile properties for specific user from nintex forms using following code. i am facing Access Denied issue for the url. Can someone help me on this.
var appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
var hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
NWF$.getScript(hosturl + "/_layouts/15/SP.RequestExecutor.js").then(function () {
NWF$.getScript(hosturl + "/_layouts/15/sp.userprofiles.js").then(function () {
//loaded user profile and request executor
execCrossDomainRequest ();
});
});
function execCrossDomainRequest() {
alert('crossrequest started');
debugger;
var strAccountName=” i:0#.f|membership|username@tester023.onmicrosoft.com”;
// var url = appweburl + "/_api/SP.AppContextSite(@target)/SP.UserProfiles.PeopleManager/GetPropertiesFor(@v)?@v='" + encodeURIComponent(strAccountName) + "'&@target='" + hostweburl + "'";
var url = appweburl +"/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(@v)?@v='" + encodeURIComponent(strAccountName) + "'";
var requestHeaders = {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
};
var executor = new SP.RequestExecutor(appweburl);
alert(url);
executor.executeAsync({
url: url,
contentType: "application/json;odata=verbose",
method: "GET",
headers: requestMainHeaders,
success: function (data) {
alert('success request');
},
fail: function (error) {
alert('failed request');
},
})
}
}