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

Jasper Report calling in ASP.Net displays 405 Method Not Allowed error


ashn

Recommended Posts

Hi,

I want to call the jasper report in ASP.NET web application.
So I done the following implementation

1. Created Test Report (TestReport.jrxml file) in Jasper Report Studio. Currently report has no parameter.
2. Added report in Jasper Report Server.

testreport_server.png.9996fc1d6d333b1af7f0ae469a6216ac.png
3. Tested above report in Jasper Report Server. It loads the data properly.
4. Now, I want to call that report in Asp.net, so added following code

public void DownloadReport()
{
            WebClient httpclient = new WebClient();

            //Authentication credentials
            httpclient.Credentials = new NetworkCredential("jasperadmin", "jasperadmin");

            httpclient.Headers.Add("Content-Type", "application/x-www-form-urlecoded");

            string requestXml;

            /*Report without parameter*/
            requestXml = "<resourceDescriptor name="TestReport" wsType="reportUnit" uriString= "/jasperserver/rest/reports/TestReport"";
            requestXml += " isNew="false">";
            requestXml += "</resourceDescriptor>";

            string uploadReport = "http://localhost:8080/jasperserver/rest/reports/TestReport?RUN_OUTPUT_FORMAT=PDF";

            //Sent PUT
            string requestAllResult = httpclient.UploadString(uploadReport, "PUT", requestXml);

            //Extract uuid, filename is always report
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(requestAllResult);

            XmlNode node = doc.DocumentElement.SelectSingleNode("uuid");
            string uuid = node.InnerText;

            //Build GET Url
            string reportURL = "http://localhost:8080/jasperserver/rest/reports/";
            reportURL += uuid;
            reportURL += "?file=report";

            //Get Report
            string report;
            //Get Session Cookie
            string session = httpclient.ResponseHeaders.Get("Set-Cookie");
            //Set Session Cookie
            httpclient.Headers.Add("Cookie", session);

            //Get Report
            report = httpclient.DownloadString(reportURL);
}

But after running code, 405 Method not allowed error is occurred at following line.
string requestAllResult = httpclient.UploadString(uploadReport, "PUT", requestXml);

Please refer below error message

error.png.a149862efab53239adbb3ffa46b4d249.png

 

I also refer following link, but nothing is working for me.
https://community.jaspersoft.com/questions/824432/using-rest-service-aspnet

I am new to Jasper Report. So may be I am doing something wrong here.
Please assist.

Thanks

Link to comment
Share on other sites

  • 6 months later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

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