cancel
Showing results for 
Search instead for 
Did you mean: 

The requests received by the Report Processing Server have the format of an old version

mhswa
Discoverer

Hi everyone,

I recently upgraded to the latest service pack and patch for Crystal Reports 2020 and have also installed Crystal Reports Server. I've developed a program in Visual Studio that attempts to fetch a report created in Crystal Reports 2020, but I'm encountering several errors.

I'm uncertain whether the problem stems from the necessity to author the report in Crystal Reports Enterprise. My research indicates this was a requirement in older versions, but I haven't found conclusive information regarding the 2020 version. Additionally, I will share my Visual Studio code for further insight.

Any guidance or suggestions would be greatly appreciated.

<error>
    <error_code>CRR 00107</error_code>
    <message>The requests received by the Report Processing Server have the format of an old version. Please ask your system administrator to upgrade. (CRR 00107, )</message>
</error>

Failed to create report instance. Status code: InternalServerError
Response: <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<error>
    <error_code>CRR 00107</error_code>
    <message>The requests received by the Report Processing Server have the format of an old version. Please ask your system administrator to upgrade. (CRR 00107, )</message>
</error>

 Here is my program 

using System;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

class Program
{
    static readonly HttpClient client = new HttpClient();

    static async Task Main(string[] args)
    {
        string baseUri = "http://Endpoint:8080/XXXX";
        string username = "Username";
        string password = "Password";
        string reportId = "7087";
        int pickslipNumber = 615710;

        string logonToken = await AuthenticateAndGetLogonToken(baseUri, username, password);
        if (string.IsNullOrEmpty(logonToken))
        {
            Console.WriteLine("Authentication failed.");
            return;
        }
        Console.WriteLine($"Authentication successful. Logon Token: {logonToken}");

        string instanceForm = await RetrieveInstanceForm(baseUri, reportId, logonToken);
        if (!string.IsNullOrEmpty(instanceForm))
        {
            string instanceId = await CreateReportInstance(baseUri, reportId, logonToken, instanceForm, pickslipNumber);
            if (!string.IsNullOrEmpty(instanceId))
            {
                Console.WriteLine($"Report instance created successfully. Instance ID: {instanceId}");
            }
        }
    }

    static async Task<string> AuthenticateAndGetLogonToken(string baseUri, string username, string password)
    {
        string authUrl = $"{baseUri}/logon/long";
        var authPayload = $"<attrs xmlns='http://www.sap.com/rws/bip'>" +
                          $"<attr name='userName' type='string'>{username}</attr>" +
                          $"<attr name='password' type='string'>{password}</attr>" +
                          $"<attr name='auth' type='string' possibilities='secEnterprise,secLDAP,secWinAD'>secEnterprise</attr>" +
                          $"</attrs>";

        HttpContent content = new StringContent(authPayload, Encoding.UTF8, "application/xml");

        var response = await client.PostAsync(authUrl, content);

        if (response.IsSuccessStatusCode)
        {
            var data = await response.Content.ReadAsStringAsync();
            return ExtractLogonToken(data);
        }

        return null;
    }

    static string ExtractLogonToken(string xmlResponse)
    {
        var xDoc = XDocument.Parse(xmlResponse);
        XNamespace ns = "http://www.sap.com/rws/bip";
        var logonTokenElement = xDoc.Descendants(ns + "attr").FirstOrDefault(x => x.Attribute("name")?.Value == "logonToken");
        return logonTokenElement?.Value;
    }

    static async Task<string> RetrieveInstanceForm(string baseUri, string reportId, string logonToken)
    {
        string url = $"{baseUri}/infostore/{reportId}/rpt/instance";

        client.DefaultRequestHeaders.Clear();
        client.DefaultRequestHeaders.Add("X-SAP-LogonToken", $"\"{logonToken}\"");

        var response = await client.GetAsync(url);

        if (response.IsSuccessStatusCode)
        {
            string instanceForm = await response.Content.ReadAsStringAsync();
            Console.WriteLine("Instance Form: " + instanceForm);
            return instanceForm;
        }
        else
        {
            Console.WriteLine($"Failed to retrieve instance form. Status code: {response.StatusCode}");
            Console.WriteLine($"Response: {await response.Content.ReadAsStringAsync()}");
            return null;
        }
    }

    static async Task<string> CreateReportInstance(string baseUri, string reportId, string logonToken, string instanceForm, int pickslipNumber)
    {
        string url = $"{baseUri}/infostore/{reportId}/rpt/instance";

        XDocument instanceDoc = XDocument.Parse(instanceForm);
        XNamespace ns = "http://www.w3.org/2005/Atom";

        var pickslipNumberEntry = instanceDoc.Descendants(ns + "entry")
            .FirstOrDefault(e => e.Element(ns + "id")?.Value == "PickslipNumber");

        if (pickslipNumberEntry != null)
        {
            var contentElement = pickslipNumberEntry.Element(ns + "content");
            if (contentElement != null)
            {
                var attrsElement = contentElement.Element(ns + "attrs");
                if (attrsElement != null)
                {
                    var valueAttr = attrsElement.Element(ns + "attr");
                    if (valueAttr != null)
                    {
                        valueAttr.SetValue(pickslipNumber);
                    }
                    else
                    {
                        attrsElement.Add(new XElement(ns + "attr", new XAttribute("name", "value"), new XAttribute("type", "number"), pickslipNumber));
                    }
                }
                else
                {
                    contentElement.Add(new XElement(ns + "attrs", new XElement(ns + "attr", new XAttribute("name", "value"), new XAttribute("type", "number"), pickslipNumber)));
                }
            }
        }

        string requestBody = instanceDoc.ToString();

        HttpContent content = new StringContent(requestBody, Encoding.UTF8, "application/xml");

        client.DefaultRequestHeaders.Clear();
        client.DefaultRequestHeaders.Add("X-SAP-LogonToken", $"\"{logonToken}\"");

        Console.WriteLine("Request URL: " + url);
        Console.WriteLine("Request Body: " + requestBody);

        var response = await client.PostAsync(url, content);

        Console.WriteLine("Response Status Code: " + response.StatusCode);
        Console.WriteLine("Response Content: " + await response.Content.ReadAsStringAsync());

        if (response.IsSuccessStatusCode)
        {
            string instanceId = await response.Content.ReadAsStringAsync();
            return instanceId;
        }
        else
        {
            Console.WriteLine($"Failed to create report instance. Status code: {response.StatusCode}");
            Console.WriteLine($"Response: {await response.Content.ReadAsStringAsync()}");
            return null;
        }
    }
}
Tdkmatt
Discoverer
0 Kudos

This post shows CR4R is becoming EOL, So not sure if making the report in a lower version then updating CR and then re saving would be an issue or not?

https://community.sap.com/t5/technology-blogs-by-sap/moving-from-crystal-reports-for-enterprise-to-c...

Accepted Solutions (0)

Answers (1)

Answers (1)

DellSC
Active Contributor
0 Kudos

Which version of Crystal Server are you using?  The version of Crystal Report and the version of Crystal Reports Server must match for things to work correctly.

I see that you're using the REST API - the "Crystal Reports" part of this API currently will only work with Crystal for Enterprise reports.  From my experience, I know that the BI Platform REST API will allow you to schedule reports and get instances from the server.  However, I've had better success with using the .NET SDK for scheduling than with using the REST API.  

-Dell

mhswa
Discoverer
0 Kudos

i am using both latest versions of Sap Designer & crystal reports, i did get a reply for SAP which is below stated "SAP Crystal Reports 2020 reports are not supported in REST SDK as of now (e.g., 4.3 SP04)" they then asked "Can you please confirm if you can use Open document for the same workflow?" so ive made some new code and i can form a URL and generate a report via the opendoc link but i cant seem to download the PDF directly regardless of the output option in the URL