Jump to content
JasperReports Library 7.0 is now available ×

How to use REST v2 API to change Active Theme


Thato

Recommended Posts

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi Thato
You utilizing Community Edition or Pro as the rest request stucture changes. 
So the manual gives example, but is focused on Jasper Pro and assuming you have already created an org called "Audit"
The example is 
PUT http://localhost:8080/jasperserver-pro/rest_v2/organizations/Audit
Payload will have content type : application/json
With json payload being :
{"theme":"jasper_dark"}

But i'll look into and test out how to do this in CE. As "organizations" do not work the same in CE.
;-)

Link to comment
Share on other sites

Ok here we go.
The REST api call mentioned in documentation is for pro only. 

So this could be a work around. 

Do a GET request with jasper url and add flow.html?_flowId=searchFlow to the url. 

Example http://localhost:8081/jasperserver/flow.html?_flowId=searchFlow

Then in the Body you receive back, you need to look for __jrsConfigs__.flowExecutionKey = YOU_NEEd_THIS_VALUE; in the body.

  • Note the value flowExecution key will change from time to time, depending on how long the time lapse it between requests, change in users etc.

Next you need to do a POST request.

 

Here is example of POST message : 

url: http://localhost:8081/jasperserver/flow.html?_flowExecutionKey=THE_ABOVE_Key_Value &_eventId=setActiveTheme

 

Headers: 

X-REMOTE-DOMAIN : 1

Content-Type : application/x-www-form-urlencoded

 

BODY: (Form)

folderUri=/themes/jasper_dark

 

⌂⌂⌂⌂

I tested the above REST call multiple time, I just updated the folderUri and the execution Key from time to time. All worked and I received a 200 response. 

 

Side note for manual testing, another way to get hold of the execution key is via the developer console. 

After signing into Jasper. 

Use Console tab and run: 

__jrsConfigs__.flowExecutionKey

this should return the code for you.

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