trboyden Posted September 2, 2019 Share Posted September 2, 2019 JasperServer Version: 7.2.0.NET Framework Version: 4.6.1Trying 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] Link to comment Share on other sites More sharing options...
swood_1 Posted September 4, 2019 Share Posted September 4, 2019 With REST or any API call from a remote location, you don't want to give much information away for security purposes.Where there any exceptions logged on the JasperReports Server side? Link to comment Share on other sites More sharing options...
trboyden Posted September 4, 2019 Author Share Posted September 4, 2019 No, nothing was output to the jasperserver.log file. Anywhere else I can/should look? Link to comment Share on other sites More sharing options...
trboyden Posted September 4, 2019 Author Share Posted September 4, 2019 No, nothing was output to the jasperserver.log file. Anywhere else I can/should look? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now