cancel
Showing results for 
Search instead for 
Did you mean: 

Rest : update person problem

dfr
Champ in-the-making
Champ in-the-making
hello,

I try to use PUT : /api/people/{userName} for update a user.
I'm use this API in a webscript in a spring surf application with remote call.

I use this code :

tmpUser = {};
tmpUser.firstName = objFrm.firstName;
tmpUser.lastName = objFrm.lastName;
tmpUser.email = objFrm.email;
tmpUser.telephone = objFrm.telephone;
tmpUser.mobile = objFrm.mobilPhone;
tmpUser.skype = objFrm.skype;
tmpUser.instantmsg = objFrm.instantMsg;
tmpUser.googleusername = objFrm.googleUsername;
tmpUser.location = objFrm.location;
tmpUser.persondescription = objFrm.biography;
tmpUser.organisation = objFrm.organization;
tmpUser.organizationId = objFrm.organization;
tmpUser.jobtitle = objFrm.jobTitle;
tmpUser.companyemail = objFrm.companyEmail;
tmpUser.companytelephone = objFrm.companyTelephone;
tmpUsercompanyfax = objFrm.companyFax;
tmpUser.companyaddress1 = objFrm.companyAddress1;
tmpUser.companyaddress2 = objFrm.companyAddress2;
tmpUser.companypostcode = objFrm.companyPostcode;
tmpUser.companyaddress3 = objFrm.companyAddress3;
      
var resultUser = connector.put("/api/people/" + user.name, jsonUtils.toJSONString(tmpUser), "application/json");

Where objFrm is a json object create from html Form and send to my webscript by json object.
All properties are updated except persondescription and googleusername and i don't know why !
Of course i have checked values of tmpUser before call for all properties and it is ok !
I have read all names of properties for tmpUser in resultUser object.

I'm sure call with PUT method return is ok (objResult is ok and other properties are updated) but persondescription is allaws reset with empty string and googleusername is never update.
I know this because i have changed this two properties by share and try to update it with my surf project.
If i delete code line for update persondescription old value persit (value set with share) but if i put line code persondescription is reset to empty string !
For googleusername value set with share allaws persit (with and without line code for update)


Sorry for my poor english and thank you for help or idea …
1 REPLY 1

dfr
Champ in-the-making
Champ in-the-making
i look in alfresco webscript person.put.json.js and i can see that googleusername is not present and persondescription is d:content type and not d:text so i made my webscript, it is the same of alfresco one, but i have add update for googleusername property

if (!json.isNull("googleusername"))
{
   person.properties["googleusername"] = json.get("googleusername");
}


and i have fix update for persondescription,
before

if (!json.isNull("persondescription"))
{
   person.properties["persondescription"] = json.get("persondescription");
}

replace with

if (!json.isNull("persondescription"))
   {
      person.properties["cm:persondescription"].content = json.get("persondescription");
   }

I deployed my webscript on alfresco and i call this one, it works.

I use Alfresco Community v4.2.0 and i just start with alfresco, so for my research to fix my problem i can see another way to update user. Share dont use person.put.json.js for update user but slingshot/person/userprofile.post.json.js and this one works good. I found it in debug mode on alfresco when using share, nothing in documentation but there are all webscript to update user, avatar or status.