error when creating a user through the jasper REST api

1

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.

 

<user>
<username>Alice</username>
<password>password</password>
<fullName>Alice Adams</fullName>
<tenantId>tenantOrg</tenantId>
</user>
 
Once I called that REST API with above given userDescriptor it gives me an error as follows
 
INFO [com.jaspersoft.jasperserver.rest.sample.RestAPIUtils] response status line: HTTP/1.1 400 Bad Request
 
appreciate if somebody can help me to resolve this issue im suffering.
 
Thanks.
Aruna.Silva's picture
Joined: Apr 23 2013 - 4:15am
Last seen: 5 years 8 months ago

2 Answers:

0

It seems that you're descriptor is correct, when I use it at the same url it works. Are you using a PUT request ?

waal's picture
36
Joined: Nov 6 2012 - 2:22pm
Last seen: 4 years 11 months ago

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

csaurav80 - 5 years 10 months ago

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.

waal - 5 years 10 months ago
0

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>

bquinn's picture
1
Joined: Dec 19 2011 - 6:12am
Last seen: 5 years 7 months ago
Feedback