Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3560

Report using restful API is not fetching the data

$
0
0

Hi ,

The Report downloaded using the RestFul API(in C#) is not fetching the data,i.e, only fetching the schema of the report.we have fallowed below code to fetch the report Please find the code below

 

string userName = "XXXXXXX";

            string password = "***************";

            string auth = "secEnterprise";

            string baseURL = "*********************:6405/biprws/";

            string LogonURI = baseURL + "logon/long";

            string InfoStoreURI = baseURL + "raylight/v1/documents/56547"; //5385 is the document id

          

            string rwsLogonToken;

 

 

            try

            {

                //Making GET Request to  /logon/long to receive XML template.

                WebRequest myWebRequest = WebRequest.Create(LogonURI);

                myWebRequest.ContentType = "application/xml";

                myWebRequest.Method = "GET";

 

 

 

 

                //Returns the response to the request made

                WebResponse myWebResponse = myWebRequest.GetResponse();

                //Creating an instance of StreamReader to read the data stream from the resource

                StreamReader sr = new StreamReader(myWebResponse.GetResponseStream());

                //Reads all the characters from the current position to the end of the stream and store it as string

                string output = sr.ReadToEnd();

                //Initialize a new instance of the XmlDocument class

                XmlDocument doc = new XmlDocument();

                //Loads the document from the specified URI

                doc.LoadXml(output);

 

 

 

 

                //Returns an XmlNodeList containing a list of all descendant elements

                //that match the specified name i.e. attr

                XmlNodeList nodelist = doc.GetElementsByTagName("attr");

                //  Add the logon parameters to the attribute nodes of the document

                foreach (XmlNode node in nodelist)

                {

                    if (node.Attributes["name"].Value == "userName")

                        node.InnerText = userName;

 

 

                    if (node.Attributes["name"].Value == "password")

                        node.InnerText = password;

 

 

                    if (node.Attributes["name"].Value == "auth")

                        node.InnerText = auth;

                }

 

 

                //Making POST request to /logon/long to receive a logon token

                WebRequest myWebRequest1 = WebRequest.Create(LogonURI);

                myWebRequest1.ContentType = "application/xml";

                myWebRequest1.Method = "POST";

 

 

                byte[] reqBodyBytes = System.Text.Encoding.Default.GetBytes(doc.OuterXml);

 

 

                Stream reqStream = myWebRequest1.GetRequestStream();

                reqStream.Write(reqBodyBytes, 0, reqBodyBytes.Length);

                reqStream.Close();

                try

                {

                    WebResponse myWebResponse1 = myWebRequest1.GetResponse();

 

 

                    //Finding the value of the X-SAP-LogonToken

                    rwsLogonToken = myWebResponse1.Headers["X-SAP-LogonToken"].ToString();

 

 

                    //Making GET request to /infostore to retrieve the contents of top level of BI Platform repository.

                    HttpWebRequest myWebRequest2 = (HttpWebRequest)WebRequest.Create(InfoStoreURI);

                    myWebRequest2.Accept = "application/pdf";

                    myWebRequest2.Headers.Add("X-SAP-LogonToken", rwsLogonToken);

                    myWebRequest2.Method = "GET";

                    WebResponse myWebResponse2 = myWebRequest2.GetResponse();

                    ///WebResponse myWebResponse2 = myWebRequest2.GetResponse();

                    // FileStream stream = new FileStream(Request.PhysicalApplicationPath + "output.pdf", FileMode.Create);

                    FileStream writeStream = new FileStream(@"D:\" + "output1.pdf", FileMode.Create, FileAccess.Write);

                    // myWebResponse2.GetResponseStream().CopyTo(stream);

                    //stream.Close();

 

 

                    string result;

                    if (ReadWriteStream(myWebResponse2.GetResponseStream(), writeStream))

                    {

                        //Code to insert data in to database goes here

                        // bool rptArchived = rptSubscrition.AddArchivedReport(userName, reportID, reportName, archivedDate, reportDescription, archivedReportPath);

                        result = "Report has been archived.";

                    }

                    else

                    {

                        result = "Unable to archive the report. Please contact administrator.";

                    }

                }

                catch (WebException ex)

                {

                    //error while accessing the network through a pluggable protocol

                  // Response.Write("<b>" + ex.Message + "</b>");

                }

                catch (Exception ex)

                {

                    //generic error

                  // Response.Write("<b>" + ex.Message + "</b>");

                }

 

 

            }

            catch (WebException ex)

            {

                //error while accessing the network through a pluggable protocol

              // Response.Write("<b>" + ex.Message + "</b>");

            }

            catch (Exception ex)

            {

                //generic error

              // Response.Write("<b>" + ex.Message + "</b>");

            }

 

 

        }

  

        private static bool ReadWriteStream(Stream readStream, Stream writeStream)

        {

            int Length = 256;

            Byte[] buffer = new Byte[Length];

            try

            {

                int bytesRead = readStream.Read(buffer, 0, Length);

                // write the required bytes

                while (bytesRead > 0)

                {

                    writeStream.Write(buffer, 0, bytesRead);

                    bytesRead = readStream.Read(buffer, 0, Length);

                }

                readStream.Close();

                writeStream.Close();

                return true;

            }

            catch (Exception)

            {

                return false;

            }

        }

we also made change in server by referring to the discussion link "http://scn.sap.com/docs/DOC-46367" made the fallowing changes in the BO server

  • Copy XercesImpl.jar from C:\Program Files (x86)\SAP BusinessObjects\tomcat\webapps\BOE\WEB-INF\eclipse\plugins\webpath.PlatformServices\web\WEB-INF\lib to C:\Program Files (x86)\SAP BusinessObjects\tomcat\webapps\AdminTools\WEB-INF\lib
  • We found that “XercesImpl.jar” is not present in  the path “C:\Program Files (x86)\SAP BusinessObjects\tomcat\webapps\AdminTools\WEB-INF\lib”

The report still downloading without data.

We are using BO 4.1  and service pack 5

Any help in this will appreciated

 

Thanks,

Sabir 


Viewing all articles
Browse latest Browse all 3560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>