cancel
Showing results for 
Search instead for 
Did you mean: 

error while creating user by restApi

priyankasoni
Champ in-the-making
Champ in-the-making
hi i ma getting error

DefaultHttpClient httpClient = new DefaultHttpClient();
         HttpPost postRequest = new HttpPost(
            "http://localhost:8080/alfresco/service/api/people");
   
         StringEntity input = new StringEntity("{userName : 'testuser' , password: 'testpassword' , firstName : 'testfirst', lastName : 'testlast', email : 'testemail@test.com',  disableAccount: false, quote: -1, groups: []}");
         input.setContentType("application/json");
         postRequest.setEntity(input);
   
         HttpResponse response = httpClient.execute(postRequest);
   
         if (response.getStatusLine().getStatusCode() != 201) {
            throw new RuntimeException("Failed : HTTP error code : "
               + response.getStatusLine().getStatusCode());
         }
   


plz tell where is problem?
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
It would help if you posted the error message.   I spot a typo above … its quota not quote.

priyankasoni
Champ in-the-making
Champ in-the-making
hi the error is
Exception in thread "main" java.lang.RuntimeException: Failed : HTTP error code : 401
   at HttpClientPostmethod.main(HttpClientPostmethod.java:25)