Get error 400:bad request when I add roles to Create User REST v2

I am not sure what is going worng with the create user api with roles. 

Observations:

1. When fired without the roles it works fine, the payload is given below

{

  "fullName": "unittestuser",

  "emailAddress": null,

  "enabled": true,

  "password": "39HN=K?E",

  "roles": null

}

2. when same endpoint is invoked with the addition of roles then it fails giving the http error code 400 (bad request)

{

  "fullName": "unittestuser",

  "emailAddress": null,

  "enabled": true,

  "password": "39HN=K?E",

  "roles": [

    {      "name": "unittest"    },

    {      "name": "UsernamePasswordAuthentication"    },

    {      "name": "Platform_NamedUser"    },

    {      "name": "Platform_Anyone"    },

    {      "name": "Platform_Metadata_MetadataInitializeUser"    }

  ]

}

3. The roles part works when the default roles shipped with Jaspersoft server installation are sent. 

{

  "fullName": "unittestuser3",

  "emailAddress": null,

  "externallyDefined": false,

  "enabled": true,

  "password": "39HN=K?E",

   "roles": [

    {      "name": "ROLE_USER"    },

     {      "name": "ROLE_ADMINISTRATOR"    }

  ]

}

 

 

I have checked the the new roles which I have created are present on the Jasperserver before the create user is hit, so I am not sure what is going wrong with the newly created roles. I am using REST api v2 for role creation as well as user creation.

Let me know if anyone has a clue.

vgaikwad's picture
Joined: Oct 19 2015 - 10:25pm
Last seen: 3 years 4 months ago

@hozawa - I got the same error even after trying insert and then update. Basically the request does not have any difference in create and update, both are http 'put'. 

vgaikwad - 6 years 5 months ago

1 Answer:

Had the same problem. I think it was that JasperReports Server wants the user created first and then roles assigned (using PUT).

http://community.jaspersoft.com/documentation/tibco-jasperreports-server...

hozawa's picture
177893
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 12 months ago
Feedback