Advanced Web Intelligence Handling

Using REST API to retrieve a Web Intelligence Documents and Reports

In this section, we use web service calls to the BusinessObjects system, you can find full documentation to the Web Intelligence web services in the SAP BusinessObjects RESTful Web Service SDK User Guide for Web Intelligence and the BI Semantic Layer.

Prerequisites

  • Credentials with sufficient privileges for running the report.
  • The id of the document, and for CSV the report ID.
    • Call <BO_URL>/raylight/v1/documents/ with Accept: application/json for a list of documents, <BO_URL>/raylight/v1/documents/<document_id>/reports with Accept: application/json for a list of reports belonging to the document.
  • Redwood Server 9.2.8.8 or later.

Procedure

In the following procedures, you create definitions for a Chain that logs on to BusinessObjects, retrieves some documents and reports, and logs off.

Retrieve the Logon Token

In Business Objects CMC, navigate to Applications > RESTfull Web Service, take note of the Access URL which will be referred to as <BO_URL> in this procedure.

  1. Navigate to Definitions > Processes, choose New Process Definition, select HTTP/REST.
  2. Fill GetLogonToken in the Name field, see Source below for the source.
  3. On the Parameters tab:
    1. In the HTTP_URL parameter, fill <BO_URL>/logon/long.
    2. In the HTTP_Method parameter, fill POST.
    3. Add a parameter named Username.
    4. Add a parameter named Password, select Password in the Parameter Options to hide the password in the user interface.
    5. Add a parameter named AuthType.
    6. Add a parameter named attr with DirectionOut; this parameter will contain the SAP logon token.
  4. Click Save & Close.

Retrieve a PDF Report

  1. Navigate to Definitions > Processes, choose New Process Definition, select HTTP/REST.
  2. Fill GetReportPDF in the Name field, see GetReportPDF Source below for the source.
  3. On the Parameters tab:
    1. In the HTTP_URL field, fill <BO_URL>/raylight/v1/documents/<document_id>.
    2. In the HTTP_Method, fill GET.
    3. Add a parameter named Format with the default value application/pdf.
    4. Add a parameter named LogonToken.
  4. On the Options tab, select PortableDocumentFormat in the Default Output Format field.
  5. Click Save & Close.

Retrieve a CSV Report

  1. Navigate to Definitions > Processes, choose New Process Definition, select HTTP/REST.
  2. Fill GetReportCSV in the Name field, see GetReportPDF Source below for the source.
  3. On the Parameters tab:
    1. In the HTTP_URL field, fill <BO_URL>/raylight/v1/documents/<document_id>/reports/<report_id>.
    2. In the HTTP_Method, fill GET.
    3. Add a parameter named Format with the default value text/csv.
    4. Add a parameter named LogonToken.
  4. On the Options tab, select CSV in the Default Output Format field.
  5. Click Save & Close.

Release the Logon Token

  1. Navigate to Definitions > Processes, choose New Process Definition, select HTTP/REST.
  2. Fill ReleaseLogonToken in the Name field, see Source below for the source.
  3. On the Parameters tab:
    1. In the HTTP_URL parameter, fill <BO_URL>/logoff.
    2. In the HTTP_Method parameter, fill POST.
    3. Add a parameter named LogonToken.
  4. Click Save & Close.

Create a Chain Definition

  1. Navigate to Definitions > Chains and choose New Chain Definition.
  2. In the Name field, fill JC_BOReport.
  3. On the Parameters tab:
    1. Add a parameter named Username.
    2. Add a parameter named Password, select Password in the Parameter Options to hide the password in the user interface.
    3. Add a parameter named AuthType, select List in the Simple Constraint Type field, fill secEnterprise,secLDAP,secWinAD,secSAPR3 into the Simple Constraint Data field.
  4. On the Diagram tab:
    1. Under Step 1, choose the first process and fill GetLogonToken into the Process Definition field.
    2. Map parameters Username, Password, AuthType to their respective Chain parameters.
    3. Add another Step by choosing the [+] to the right of Step 1.
    4. Fill GetReportPDF into the Process Definition field of process 1 of Step 2.
    5. Map parameter LogonToken to parameter attr of GetLogonToken in the first Step.
    6. Add another process to Step 2.
    7. Fill GetReportCSV into the Process Definition field of process 2 of Step 2.
    8. Map parameter LogonToken to parameter attr of GetLogonToken in the first Step.
    9. Add another Step by choosing the [+] to the right of Step 2.
    10. Fill ReleaseLogonToken into the Process Definition field of process 1 of Step 3.
    11. Map parameter LogonToken to parameter attr of GetLogonToken in the first Step.
  5. Click Save & Close.

GetLogonToken Source

Copy
<attrs xmlns="http://www.sap.com/rws/bip">
  <attr name="password" type="string">${Password}</attr><attr name="clientType" type="string"></attr>
  <attr name="auth" type="string" possibilities="secEnterprise,secLDAP,secWinAD,secSAPR3">${AuthType}</attr>
  <attr name="userName" type="string">${Username}</attr>
</attrs>
[headers]
Content-Type=application/xml

GetReport Source

Copy
[Headers]
X-SAP-LogonToken=${LogonToken}
Accept=${Format}

Release LogonToken Source

Copy
[Headers]
X-SAP-LogonToken=${LogonToken}

Run and Retrieve Web Intelligence Reports using cURL, xmlstarlet, and jq

Copy
#BOBJ_SERVER URL, defaults to https://bobj.example.com:6405/biprws
#USERNAME: jdoe
#PASSWORD: mySecret
#REPORT: defaults to 'Sections Demo'
#REPORT_FORMAT=application/pdf

: ${REPORT:=Sections Demo}
: ${BOBJ_SERVER:=https://bobj.example.com:6405/biprws}

LOGON_URL="${BOBJ_SERVER}/logon/long"
LOGOFF_URL="${BOBJ_SERVER}/logoff"
DOC_URL="${BOBJ_SERVER}/raylight/v1/documents"
XML_HEADER="Content-Type: application/xml"
JSON_HEADER="Accept: application/json"
FORMAT_HEADER="Accept: ${REPORT_FORMAT}"

tokenValue=$(curl -X POST -d @- -H "${XML_HEADER}" "${LOGON_URL}" <<EOF
<attrs xmlns="http://www.sap.com/rws/bip">
  <attr name="password" type="string">${PASSWORD}</attr>
  <attr name="clientType" type="string"></attr>
  <attr name="auth" type="string" possibilities="secEnterprise,secLDAP,secWinAD,secSAPR3">secEnterprise</attr>
  <attr name="userName" type="string">${USERNAME}</attr>
</attrs>
EOF
) | xmlstarlet sel -T -N x="http://www.sap.com/rws/bip" -t -v '//x:attr'

#Retrieve all reports
curl -G -s -H "Accept: application/json" -H X-SAP-LogonToken:"${tokenValue}" "${DOC_URL}" > all_reports.json

#REPORT parameter with the name of the report as displayed in CMC
webi_report=$(jq '.documents[] | .[] | select(.name=="`${REPORT}`") | .id ' all_reports.json)

echo "Retrieving report ${REPORT} with id: ${webi_report}"
curl -G -s -H "${FORMAT_HEADER}" -H X-SAP-LogonToken:"${tokenValue}" "${DOC_URL}/${webi_report}" > "export_${webi_report}.pdf"

echo "Logging off..."
curl -X POST -H X-SAP-LogonToken:"${tokenValue}" "${LOGOFF_URL}"

See Also

Scheduling SAP BusinessObjects Reports