3

I can update my own profile properties but i cant update other users profile properties. When i do i'll get an "you are not authorized.." error. I have administration rights.

Here is my function to write profile properties

function writeProfileProperties(accountName, propertyKey){
      var clientContext = new SP.ClientContext.get_current();
      var peopleManager = new SP.UserProfiles.PeopleManager(clientContext); 
       clientContext.executeQueryAsync(function(){
       peopleManager.setSingleValueProfileProperty(accountName, propertyKey, "Value updated from JSOM!");
       clientContext.executeQueryAsync(function(){

            alert("properties updated!");
        }, 
        function(sender,args){
            //On Error
            alert(args.get_message());
        });
    }, function(sender,args){
        //On Error
        alert(args.get_message());
    }); 
}
  • Did you give the app write permissions to user profiles? – wjervis Jan 21 '16 at 14:57
  • Its not an app. Its a javascript file inside a content editor web part on my sitecollection – Anders Jan 21 '16 at 15:18
  • Ah. Are you an admin of the tenant? If so, try going to the user profile settings, make yourself a site collection admin of another user, and see if that lets you update their properties. Also, can you update your question with the exact error text? – wjervis Jan 21 '16 at 15:20
  • Im not an admin as in the name admin i just have administration rights for my test sitecollection. Or what do you mean by admin of the tenant? The exact error message is: "Access denied. You do not have permission to perform this action or access this resource." – Anders Jan 21 '16 at 15:41
  • Can you access the admin area for your tenant? Would be located at https://<tenant>-admin.sharepoint.com/. So if your tenant is contoso, and your url is https://contoso.sharepoint.com/, your admin url would be https://contoso-admin.sharepoint.com/. – wjervis Jan 21 '16 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.