AnsweredAssumed Answered

create user from java code

Question asked by binduj on Apr 29, 2011
Latest reply on Feb 15, 2012 by jpotts
Hi,

I'm trying to create a new alfresco user from our java application using
http://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference#Add_Person

The way Im trying is
1. first log-in as user(who has admin privileges). This returns an alf_ticket.
2. Using the ticket, try to invoke the Add person request.

When I tried as above, Im getting a 401 Authentication error. More details below:

This is the post request we are sending:-

post=POST /alfresco/service/api/people?alf_ticket=TICKET_07eb3b3751b5d493df751c7c473776f604f23791 HTTP/1.1
Host: 192.168.225.82
Authorization: Basic YWRtaW46bVVmYXo2aVA=
User-Agent: HPi Sync
Connection: close
Content-Type: application/json
Content-Length: 119

{"password" : "pasword", "userName" : "50000", "email" : "a@b.com", "firstName" : "firstName", "lastName" : "lastName"}
This is the error we got:-

response=HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json;charset=UTF-8
Date: Fri, 29 Apr 2011 06:13:01 GMT
Connection: close


  "status" :
  {
    "code" : 401,
    "name" : "Unauthorized",
    "description" : "The request requires HTTP authentication."
  }, 
 
  "message" : "03280002 Web Script org\/alfresco\/repository\/person\/people.post requires admin authentication; however, a non-admin has attempted access.", 
  "exception" : "org.springframework.extensions.webscripts.WebScriptException - 03280002 Web Script org\/alfresco\/repository\/person\/people.post requires admin authentication; however, a non-admin has attempted access.",


Not sure if this is the right approach that I should follow. Please suggest.
Or provide me some sample java code that I can use to create a new user.

Outcomes