Jump to content
We've recently updated our Privacy Statement, available here ×

trboyden

Members
  • Posts

    7
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by trboyden

  1. No, nothing was output to the jasperserver.log file. Anywhere else I can/should look?
  2. No, nothing was output to the jasperserver.log file. Anywhere else I can/should look?
  3. JasperServer Version: 7.2.0 .NET Framework Version: 4.6.1 Trying to create a JasperServer client library to use with another .NET-based application to do reporting. I built the following C# class to handle the reportExecutions method for the JasperServer REST API. Using the same parameters in Postman (baseUrl, authorization, json request), I get the expected report execution response, so I know my server configuration and credentials are correct. However, when I try to send the same request using the HttpClient module, I get an error response back with error code: generic.error.message (real helpful info there TIBCO, NOT!). I would appreciate it if someone can take a peek at my code below and see if you can spot where my issue could be coming from. Thanks! public class reportExecutions { static HttpClient client = new HttpClient(); public static async void sendReportExecutionRequestAsync(string baseUrl, string authorization, string request) { // baseUrl = https://hostname/jasperserver/rest_v2 // authorization = base64 encoded user:password // request = {"reportUnitUri":"/reports/HelloWorld","async":true,"freshData":false,"saveDataSnapshot":false,"outputFormat":"pdf","interactive":false,"ignorePagination":false,"pages":null,"parameters":null} string restMethod = "/reportExecutions"; using (var requestMessage = new HttpRequestMessage(HttpMethod.Post, baseUrl + restMethod)) using (HttpContent requestContent = new StringContent(request, Encoding.UTF8, "application/json")) { requestMessage.Headers.Add("Authorization", authorization); requestMessage.Headers.Add("Accept", "application/json"); requestMessage.Method = HttpMethod.Post; // DEBUG: See what the json content being sent looks like: string content = requestContent.ReadAsStringAsync().Result; Debug.WriteLine(content); using (HttpResponseMessage response = await client.SendAsync(requestMessage)) { using (HttpContent responseContent = response.Content) { var result = await responseContent.ReadAsStringAsync(); if (result != null) { if (result.Contains("{"message":")) { models.errorResponse er = JsonConvert.DeserializeObject<models.errorResponse>(result); Debug.WriteLine("Error Response"); Debug.WriteLine("Message: " + er.message); Debug.WriteLine("Error Code: " + er.errorCode); Debug.WriteLine("Error UID: " + er.errorUid); } else { models.reportExecutionResponse rer = JsonConvert.DeserializeObject<models.reportExecutionResponse>(result); Debug.WriteLine("Report Execution Result"); Debug.WriteLine("Report URI: " + rer.reportURI); Debug.WriteLine("Request ID: " + rer.requestId); Debug.WriteLine("Status: " + rer.status); Debug.WriteLine("Exports"); foreach (models.Export e in rer.exports) { Debug.WriteLine("Export ID: " + e.id); Debug.WriteLine("Status: " + e.status); } } } else { Debug.WriteLine("No Content, Status Code: " + response.StatusCode); } } } } } }[/code]
  4. See fix here: https://community.jaspersoft.com/wiki/popup-spinning-endlessly-due-messing-token-nginx-proxy Jasper Server is passing headers with underscores in them and NGINX is configured by default not to allow them. Adding the underscores_in_headers on; directive under the http section of the nginx.conf file in /etc/nginx fixes the issue.
  5. I am able to send a report request, passing in json as a report input control. I get the response back as json, with the applicable request and export IDs. I go to poll the requestExecution service for the status of the request and it throws a 404 error that the request ID is not found. What am I missing? Csharp code below... using Newtonsoft.Json.Linq;using System;using System.Diagnostics;using System.Net;namespace JasperReportsClient{ class Program { static void Main(string[] args) { WebClient client = new WebClient(); CredentialCache creds = new CredentialCache(); creds.Add(new Uri("http://<Hostname>:8080/"), "Basic", new NetworkCredential("admin", "admin")); client.Credentials = creds; string data = Uri.EscapeDataString("[{"CustNum":" 2","CustSeq":"0","Name":"Coordinated Bicycles - North"}]"); string request = "{"reportUnitUri":"/Reports/CustomerReport","async":true,"freshData":true," + ""saveDataSnapshot":false,"outputFormat":"pdf","interactive":false,"ignorePagination":true," + ""pages":null,"parameters":{"reportParameter":[{"name":"jsonString","value":["" + data + ""]}]}}"; WebHeaderCollection headers = new WebHeaderCollection(); headers.Add("Content-Type:application/json"); headers.Add("accept:application/json"); client.Headers = headers; string response = ""; response = client.UploadString("http://<Hostname>:8080/jasperserver/rest_v2/reportExecutions", request); JObject responseAsJsonObject = JObject.Parse(response); string requestId = responseAsJsonObject["requestId"].ToString(); string exportId = responseAsJsonObject["exports"][0]["id"].ToString(); string requestStatus = responseAsJsonObject["status"].ToString(); Debug.WriteLine("Request ID: " + requestId); Debug.WriteLine("Export ID: " + exportId); Debug.WriteLine("Request Status: " + requestStatus); while(requestStatus == "queued") { response = null; response = client.DownloadString("http://<Hostname:8080/jasperserver/rest_v2/reportExecutions/" + Uri.EscapeDataString(requestId) + "/status"); responseAsJsonObject = null; responseAsJsonObject = JObject.Parse(response); requestStatus = null; requestStatus = responseAsJsonObject["value"].ToString(); Debug.WriteLine("Request Status: " + requestStatus); } if(requestStatus == "ready") { string ReportOutputPath = @"\<Hostname><ReportOutputDirectory>"; string ReportOutputFile = "CustomerReport - " + DateTime.Now.ToString("yyyyMMdd_HHmmssff") + ".pdf"; client.DownloadFile("http://<Hostname>:8080/jasperserver/rest_v2/reportExecutions/" + Uri.EscapeDataString(requestId) + "/exports/" + Uri.EscapeDataString(exportId) + "/outputResource", ReportOutputPath + ReportOutputFile); Process.Start(ReportOutputPath + ReportOutputFile); } client.Dispose(); } }}[/code]
  6. As an update, and so hopefully Googlers can find a decent example to get themselves going, here is some example VB.Net code that works: Imports System.NetModule ModuleMain Sub Main() ' WebClient Class Implementation ' Dim wc As WebClient = New WebClient() ' Authorize the http request ' Dim cc As CredentialCache = New CredentialCache() cc.Add(New Uri("http://<JasperServerHostname>:8080/"), "Basic", New NetworkCredential("admin", "admin")) wc.Credentials = cc ' Set the base address of the Reports service ' wc.BaseAddress = "http://<JasperServerHostname>:8080/jasperserver/rest_v2/reports/" ' Create the inputControl parameter to send to JasperServer as a QueryString parameter ' Dim data As Specialized.NameValueCollection = New Specialized.NameValueCollection() data.Add("jsonString", Uri.EscapeDataString("[{""CustNum"":"" 2"",""CustSeq"":""0"",""Name"":""Coordinated Bicycles - North""}]")) wc.QueryString = data ' Setup the file to download the report to ' Dim outputBasePath As String = "\<ERPServerReportOutputDirectory>" Dim fileName As String = "CustomerReport-" & DateTime.Now.ToString("yyyyMMdd_HHmmssff") & ".pdf" ' Submit the http request and get the output resource ' wc.DownloadFile("Reports/CustomerReport.pdf", outputBasePath & fileName) ' Launch the PDF file using the default PDF viewer application ' System.Diagnostics.Process.Start(outputBasePath & fileName) End SubEnd Module[/code]Replace the values between "<Variable>" with your specific implementation configuration. As narcism mentioned, his answer, contains the information you need to setup the JasperReports jrxml file to use json as an inputControl /parameter to the report.
  7. Jasper Reports newbie here... In a nutshell, what I am looking to do is have a Jasper Report that uses json as a data source, that is passed to it at execution time, via the REST API. In more detail... The json data would come from my ERP system and would be sent to the Jasper Server as part of the web request to run the report. The output in general would be PDF, but sometimes Excel, CSV, or HTML depending on the report and the needs of the user. What are the high-level steps to do this, and can you point me in the direction of the documentation that covers each step? I have created a Jasper Report in Jaspersoft Studio, that uses a json file as its datasource via a DataAdapter. I have the Jasper Server installed and running as a Docker instance against a Mariadb cluster. Now I just need to connect the dots. The Jasper Reports server would not have direct access to the ERP system database, hence using Jasper as a web service and passing it the data I want to use in the report. Program language doesn't matter per se, but C# or Visual Basic examples would be ideal. I understand the basic concept of sending a POST request to run the report, but I don't see a way in the API that you can pass the report the data to use during execution. Thanks in advance for any assistance anyone can provide! -Tim
×
×
  • Create New...