Jump to content
Changes to the Jaspersoft community edition download ×

Need to call 2 methods to retrieve data


Recommended Posts

Hi,

I'm new to Jaspersoft, so my apologies in advance if my question applies more broadly and I'm posting in the wrong place. I'm trying to use a web service in Jaspersoft that needs a call to its Login function first. That function receives a username and password, and returns a temporary access token. That token can be used to issue another function call later that will return actual data for the report.

So far I've done the following:

  1. I created a "Login" sub-report. Use the web service data adapter, point it to the Login method, provide credentials etc. The token gets stored in the field called "token".
  2. I added a variable to that sub-report, called "accessToken", whose Expression is set to $F{token}. I can see that the correct value gets stored if I add a text field and set its expression to $V{accessToken}.
  3. I created the main report and added the sub-report to the first band. I also added an "accessToken" variable there as well. For sub-report properties, under Return Values, I set From and To to "accessToken", hoping that main report's access token varialble will be populated with the data from the sub-report.
  4. Lastly, in the Query Dialog of the main report, I set the Base URL to something like GetEmployees?accessToken=$V{accessToken} - this should return a JSON of a list of employees, if the access token is valid. However, when I try to get the server's response, I get an exception, and it looks like $V{accessToken} doesn't get substituted with the actual token value.

Is my approach generally correct? How can I use the data obtained from a sub-report in a call to another web service function? Thank you!

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

I also tried the following: the main report retrieves the access token and stores it in a field. The subreport is added to the main report with a parameter. That parameter is set to $F{token}. In the Base URI, I use $P{accessToken} as shown in the video, but that gives me a Bad Request error. 

Link to comment
Share on other sites

To clarify, the authentication is not for JasperServer, but for puling data into the report, from a Web Service. I have a web service that returns JSON data I'd like to bind to a report, but before I can pull that data, I need to get an authentication token from the same web service, by calling a Login function. I think what you are referring to is authentication for the Jasper Server itself.

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...