Hi all ,
I'm trying to create a user in jasper report server using its extended REST web service API
url what im calling is : http://localhost:8080/jasperserver-pro/rest/user and following is the user descriptor I'm sending.
2 Answers:
You need to set externallyDefined along with enabled. Also if role or user is in an org, that should be specified.
e.g.
curl -u superuser:superuser -X PUT -H "Content-Type: text/plain" -d @ops_user.xml "http://localhost:8080/jasperserver-pro/rest/user/"
where ops_user.xml is..
<user>
<enabled>true</enabled>
<externallyDefined>false</externallyDefined>
<username>johndoe</username>
<password>myPassword</password>
<fullName>John Doe</fullName>
<tenantId>organization_1</tenantId>
<emailAddress>john.doe@mail.com</emailAddress>
<roles>
<externallyDefined>false</externallyDefined>
<roleName>ROLE_OPS</roleName>
<tenantId>organization_1</tenantId>
</roles>
</user>
I am trying to create a new user by jasper rest user service api.
But I always get 400 bad request and this is what, I am trying. Can anyone point me what I am doing wrong ?
curl -i -u jasperadmin:jasperadmin -H "Content-Type: application/json" -H "Accept: application/json" -X PUT -d '{\"username\":\"mynewuser\",\"password\":\"mynewuser\",\"fullName\":\"NEWUSER\":\"emailAddress:\"user_1@test.com\"}' "http://localhost:8080/jasperserver/rest/user/"
HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 05:30:00 GMT+05:30
P3P: CP="ALL"
Set-Cookie: JSESSIONID=F7394A9F7348C22E4B264FBCEB6B828F; Path=/jasperserver
Content-Type: text/html;charset=UTF-8
Content-Length: 971
Date: Mon, 02 Sep 2013 10:32:21 GMT
Connection: close
When I run the following curl command:
curl -i -u superuser:superuser -X PUT -H "Content-Type:text/xml" -H "Accept:text/xml" -d '<user><username>Fozzie</username><password>123</password><fullName>Fozzie Bear</fullName><tenantId>develdb</tenantId></user>' "http://localhost:8080/jasperserver-pro/rest/user"
I get this output:
HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
Cache-Control: private
Expires: Thu, 01 Jan 1970 01:00:00 CET
P3P: CP="ALL"
Set-Cookie: JSESSIONID=1D193052E4313ADA2B66E073304F5756; Path=/jasperserver-pro/; HttpOnly
Content-Type: text/xml;charset=UTF-8
Transfer-Encoding: chunked
Vary: Accept-Encoding
Date: Mon, 02 Sep 2013 12:45:43 GMT
I'm not sure if jasper also supports json as request, the examples I could find are only with XML. I'm also not sure if you have to give the organization with the username. We are using the pro version, so jasperadmin is linked to an organisation there.