cancel
Showing results for 
Search instead for 
Did you mean: 

person.put

misterx
Champ in-the-making
Champ in-the-making
Hello everybody,

there is an issue related to this javascript that I may not have understood.

In my service when I call the PUT functionallity I receive HTTP code 200. Which is okay. But instead of having my user updated, I receive a json with the admin values plus my user is not being updated.

I am pretty sure I am doing everything okay.

Does any one know any problem with this person.put or maybe a json pattern that I may not be following?
3 REPLIES 3

mitpatoliya
Star Collaborator
Star Collaborator
which person webscript you are using?
Have you checked the expected input json format? as when you will be changing to PUT there is altogether different webscript will be called.

misterx
Champ in-the-making
Champ in-the-making
Thanks for the reply.

Yes I checked the expected JSON. This part is ok. I am using Fiddler to test my service and I get a 200 HTTP code with a JSON containing the Admin values. Even if I use a PUT into another user, I get the Admin values.

I am using this webscript: http://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference#Update_Person

kaynezhang
World-Class Innovator
World-Class Innovator
there maybe something wrong with your code ,following is my test code ,it works fine.

package com.kayne.local.java.webscripts;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.json.JSONObject;

public class UpdatePersonTest {

   public static void main(String[] args) {
      HttpClient client = new HttpClient();
      client.getState().setCredentials(
            new AuthScope("localhost", 8080, "Alfresco"),
            new UsernamePasswordCredentials("admin", "admin"));
      String userName = "kayne";
      String apiurl = "http://localhost:8080/alfresco/service/api/people/'+userName;
      PutMethod put = new PutMethod(apiurl);
      try {
         JSONObject person = new JSONObject();
         person.put("firstName", "kayne");
         person.put("lastName", "zhang");
         person.put("mobile", "12343424342");
         person.put("location", "N.A");
         
         System.out.println(person.toString());
         put.setDoAuthentication(true);
         put.setRequestHeader("Content-Type", "application/json");
         put.setRequestEntity(new StringRequestEntity(person.toString(),
               "application/json", "UTF-8"));

         int status = client.executeMethod(put);
         if (status != HttpStatus.SC_OK) {
            System.err.println("Method failed: " + put.getStatusLine());
         }
         String resultString = put.getResponseBodyAsString();
         System.out.println(resultString);
      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         put.releaseConnection();
      }
   }
}

please paste your code here .
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.