I'm in the process of converting an existing Cllient side Sharepoint 2013 app into Angular.
I'm at the point where i need to save a user to a list, when doing this you need to find out the userID from SP. I would normally use the following code.
function execCrossDomainRequest(selUser) {
//clear any errors
var errModalArea = document.getElementById("modalAnnouncements");
// Remove all nodes from the errAllEvents <DIV> so we have a clean space to write to
while (errModalArea.hasChildNodes()) {
errModalArea.removeChild(errModalArea.lastChild);
}
var seluser = selUser;
var executor = new SP.RequestExecutor(appweburl.toLowerCase());
// The functions successHandler and errorHandler attend the
// sucess and error events respectively.
executor.executeAsync({
url: appweburl + "/_api/SP.AppContextSite(@target)https://waybackassets.bk21.net/siteusers(@v)?@v='" + seluser + "'&@target='" + hostweburl + "'",
//url: appweburl + "/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='" + seluser + "'",
//url: appweburl + "_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='Manager')?@v='" + selManager + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: successHandler,
error: errorGetEmployee
});
}
I have adapted this to suit my Angular app...
// Get the user ID.
function getUserId(loginName) {
var loginname = loginName;
alert(loginname);
var executor = new SP.RequestExecutor();
// The functions successHandler and errorHandler attend the
// success and error events respectively.
executor.executeAsync({
url: $resource + "/_api/SP.AppContextSite(@target)https://waybackassets.bk21.net/siteusers(@v)?@v='" + loginname + "'&@target='" + $resource + "'",
//url: $resource + "/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='" + loginname + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: successHandler,
error: errorGetEmployee
});
}
However I am getting the following error when trying to save.
"invalid field or parameter url"
If I get the function that saves the record a hard coded userID then it works...
Anyone seen this?
S