I am trying to design a few desktop reports on the community version of Jaspersoft Studio 6.8.0 from JSON data sources.
I have used WGET to successfully send the POST data (api id/key) to the public REST interface at incapsula (eg my.incapsula.com/api/prov/v1/sites/list - This API document is public so no issue providing the details here, just not the keys) and get back the JSON data no problem. I have then successfully created a number of reports from the JSON data with no issue (via a JSON file data adaptor)
What I want to do now is use web service data adaptor - but while I can create it and I can see that it goes out to incapsula, the only response I get back is the error page (the JSON error page). My testnig with a REST web service I control, and I cant see the POST data being sent, dispite it being in source tab.
EG: "queryData" : "api_id=12345&api_key=2a3b4c-5d6e-7f8g-90hi-111213jklmn"
I confirm this that when I sent the WGET with the wrong API or (no API keys) I only get back the same JSON error page.
As far as I can tell, the web data handler is not sending the data properly for the POST part.
Anybody else have this problem?
Okay - After some more poking around I found out the reason and the solution.
The reason is the specific Data source I am connecting to doesn't like the content type of "application/json".
Because when I try the connection with wget it uses the content type of "application/x-www-form-urlencoded" and successfully down loads the JSON data.
So what I did was in the "Dataset and query Dialog" window, in the Source tab, I changed
"contentType" : "application/json",
"rootPath" : "",
"baseUrl" : "/api/prov/v1/sites/list"
To
"contentType" : "application/x-www-form-urlencoded ",
"rootPath" : "",
"baseUrl" : "/api/prov/v1/sites/list"
And this allowed the connection to work.
Hope this helps other people in the future.