aamitt06 Posted October 10, 2014 Share Posted October 10, 2014 I am trying to create user by following JasperServer rest api I am using JasperServer version 5.6.0 ,when I am passing put request with json data I am getting 400 Bad Request error Authenticator.setDefault(new Authenticator() { @Overrideprotected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication("jasperadmin", "jasperadmin".toCharArray()); } }); String input = "{"username":"AgentUser22","password":"jasperadmi","fullname":"Agent User","emailAddress":"aamitt06@gmail.com","enabled":true,"externallyDefined":false,"roles":[{"name":"ROLE_AGENT"}]}"; JSONObject jObject = new JSONObject(input); ClientResponse response = service.path("rest_v2").path("users").path("AgentUser22").type("application/json") .put(ClientResponse.class,jObject);' System.out.println(jObject); if (response.getStatus() != 201) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } Link to comment Share on other sites More sharing options...
aamitt06 Posted October 13, 2014 Author Share Posted October 13, 2014 After users when I am typing userid that already exists it gives me status 200 that is ok. Link to comment Share on other sites More sharing options...
Solution aamitt06 Posted October 13, 2014 Author Solution Share Posted October 13, 2014 I resolved the issue the mistake i was doing was that in String input = "{"username":"AgentUser22", ... instead of username it should be fullName and the correct fromat of descriptor should be String input = "{"fullName":"AgentUser22","password":"jasperadmi","emailAddress":"aamitt06@gmail.com","tenantid":"Ag","enabled":true,"externallyDefined":false,"roles":[{"name":"ROLE_USER"},{"name":"ROLE_VOUCHER"}]}";JSONObject jObject = new JSONObject(input); Rest would be the same as above. Link to comment Share on other sites More sharing options...
aamitt06 Posted October 16, 2014 Author Share Posted October 16, 2014 For more detail visit http://amitptechnocrat.blogspot.in/2014/10/creating-user-using-jasperserver-rest.html Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now