Jump to content
We've recently updated our Privacy Statement, available here ×

How to create user using jasper rest api?


aamitt06
Go to solution Solved by aamitt06,

Recommended Posts

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() {
  @Override

protected 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

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...