Manage reports using REST services

You can use REST services to manage templates and reports.

Report Server Rest services

The following REST services are available in Report Server:

TemplateRest

TemplateRest is used to manage the report templates: generate, list and delete templates.

URL: http://<host>:<port>/report-web/api/v1.0/applications/{applicationName}/templates

The following operations are supported on this resource:

  • GET - Gets the list of report templates
  • Example:
    • List the templates for collection type ACCDOCSET_1 for InterPlay:
    • http://localhost:8080/aiservices-reporting-web/api/v1.0/applications/default/templates?serviceType=InterPlay&requestComponent=InterPlay&targetComponent=InterPlay&targetType=COLLECTION_TYPE&targetName=ACCDOCSET&targetVersion=1&multiplicity=1
    • List the templates for object type ACCDOC_1 for InterPlay:
    • http://localhost:8080/aiservices-reporting-web/api/v1.0/applications/default/templates?serviceType=InterPlay&requestComponent=InterPlay&targetComponent=InterPlay&targetType=OBJECT_TYPE&targetName=ACCDOC&targetVersion=1&targetPath=DOC&multiplicity=1
    • List the templates for element type ACCDOC_1/LINE for InterPlay:
    • http://localhost:8080/aiservices-reporting-web/api/v1.0/applications/default/templates?serviceType=InterPlay&requestComponent=InterPlay&targetComponent=InterPlay&targetType=OBJECT_TYPE&targetName=ACCDOC&targetVersion=1&targetPath=DOC/LINE&multiplicity=1
    • List the templates for object/element types by ids for InterPlay:
    • http://localhost:8080/aiservices-reporting-web/api/v1.0/applications/default/templates?serviceType=InterPlay&requestComponent=InterPlay&targetComponent=InterPlay&targetType=OBJECT_TYPE&id=1&id=2
  • POST - Generated report templates
  • Example:
    • Generate templates for InterPlay with application name default for all collection, object and element types. The content of the JSON request is:
    • {
    • "serviceType":"InterPlay",
    • "requestComponent":"InterPlay"
    • }
  • DELETE - Deletes report templates. There are two options:
    • using the list of templates identifiers,
    • using templateName, targetName, targetVersion, targetPath, queryName.
  • If the list of templates identifiers is missing then the second option will be used.
  • Example:
    • Delete the collection templates by ids for InterPlay:
    • http://localhost:8080/aiservices-reporting-web/api/v1.0/applications/default/templates?requestComponent=InterPlay&serviceType=InterPlay&targetType=COLLECTION_TYPE&id=50
    • Delete the templates for object types with name ACCDOC and having the template name ‘default’ for InterPlay:
    • http://localhost:8080/aiservices-reporting-web/api/v1.0/applications/default/templates?requestComponent=InterPlay&serviceType=InterPlay&targetType=OBJECT_TYPE&targetName=ACCDOC&name=default

ReportRest

ReportRest is used to manage the reports: generate, list, download an register external reports.

URL: http://<host>:<port>/report-web/api/v1.0/components/{requestComponent}/reports

The following operations are supported on this resource:

  • GET - Gets the list of generated reports.
  • Example:
    • List all reports as an administration use for InterPlay:
    • http://localhost:8080/aiservices-reporting-web/api/v1.0/components/InterPlay/reports?admin=true
  • POST -Registers an externally generated report as an available report when the request media type is multipart/form-data.
  • Example:
    • Register an external report of type pdf for component InterPlay as shared report and assign the name external_report_pdf
    • {
    • "targetComponent":"InterPlay",
    • "category":"externalReports",
    • "name":"external_report_pdf",
    • "extension":"pdf",
    • "shared":"true"
    • }
  • POST - Generates a report in an asynchronous manner.
  • Example:
    • Generate an html reports for InterPlay for an object of type ACCDOC_1 having id 601 and using the specified report creator class name , the template with id 114.
    • The generated report will have the name defaultFormACCDOC_RESTApi_2015_04_01_10_30_15 and will be internationalized using english language.
    • {
    • "targetName":"ACCDOC",
    • "targetType":"OBJECT_TYPE",
    • "targetVersion":"1",
    • "multiplicity":"1",
    • "targetComponent":"InterPlay",
    • "hiddenProperties":["RECORD_TYPE","MODIFICATION_DATE","TRANSACTION_ID","ID_COLLECTION","ID_BOBJECT","VERSION","LIFECYCLE_STATUS","CREATION_AUTHOR","MODIFICATION_AUTHOR","CHANGE_STATUS_AUTHOR","NAME","EDITOR_CATEGORY","LOCK_OBJECT","CHANGE_STATUS_DATE","MODIFICATION_STATE","CREATION_DATE","SESSION_ID","ROOT_ELEMENT"],
    • "targetPath":"DOC",
    • "reportType":"html",
    • "systemParams":{"ID_BOBJECT":"601"}, //for a collection specify ID_COLLECTION, for an element specify ID_ELEMENT
    • "userLanguage":"english",
    • "reportCreatorClassName":"com.axway.ais.reporting.creators.interplay.DefaultReportCreator",
    • "reportTemplateId":"114",
    • "reportName":"defaultFormACCDOC_RESTApi_2015_04_01_10_30_15"
    • }
  • DELETE - Deletes the reports. There are two options:
    • using the list of reports identifiers
    • using the parameters creationAuthor, startDate, endDate, componentName, templateName and reportType.
  • If the list of reports identifiers is missing then the second option will be used.
  • Example:
    • Delete the reports by ids for InterPlay:
    • http://localhost:8080/aiservices-reporting-web/api/v1.0/components/InterPlay/reports?id=235&id=123
    • Delete the reports created by user Sorin as an administration user (admin=true) for InterPlay:
    • http://localhost:8080/aiservices-reporting-web/api/v1.0/components/InterPlay/reports?creationAuthor=Sorin&admin=true

To get more details about REST services parameters, the Report RESTfull API documentation can be found at http://<host>:<port>/report-web/apidocs/index.html

All REST services can be tested using Swagger UI at http://<host>:<port>/report-web/apidocs/ui.

Polling mechanism

To get the generation status of a report the user must make a request to: http://<host>:<port>/resrvport-web/api/v1.0/components/{requestComponent}/reports/status?id={id} where:

  • {id} is the id oh the report
  • {requestComponent} is the name of the request component

If the task status is IN_PROGRESS, the response is:

{"statusMap":{

"id1":"DONE",

"idn":"IN_PROGRESS"}

}

Once a report is successfully generated it can be downloaded by performing a GET request to http://<host>:<port>/resrvport-web/api/v1.0/components/{requestComponent}/reports/{id} which will return the direct access url.

Rest service response message internationalization

If there is an error for a REST request, the response contains the errorCode parameters, and the message internationalized using the language from the request header. For example:

{

"error": {

"level" : "ERROR",

"code": "error.missingReport",

"message": "=The report with id '{0}' could not be loaded or it doesn't exist. ",

"parameters": [

"5"

]

}

}

Related Links