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

Poll request status - request ID no longer exists - what am I missing?


trboyden

Recommended Posts

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]

 

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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