IBM Support

How to Retrieve and Cancel Jobs Running on a Planning Analytics as a Service Database Using REST API

How To


Summary

This document provides an example of using REST API to retrieve and cancel jobs running on a Planning Analytics as a Service database.

Environment

The steps in this document have been written for Visual Studio Code using the REST Client extension.

Sample Code:
@host = https://us-east-1.planninganalytics.saas.ibm.com
@tenant = A1B2C3D4E5C6
@tm1db = Test Database
@apiKey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@Authorization = Basic apikey:{{apiKey}}

### Authenticate using apikey.  paSession cookie set.
# @name Authenticate
GET {{host}}/api/{{tenant}}/v0/rolemgmt/v1/users/me  HTTP/1.1
Authorization: {{Authorization}}
Content-Type: application/json

### Retrieve list of jobs running on the database
# @name getJobs
GET {{host}}/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Jobs?$expand=*  HTTP/1.1
Content-Type: application/json

### Cancel running database job
### Specify jobId in URL and pass an empty body
# @name cancelJob
@jobId = 74830445-1da1-456a-be68-acac28311a3d-00
POST {{host}}/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Jobs('{{jobId}}')/tm1.Cancel  HTTP/1.1
Content-Type: application/json

{}

Steps

  • Download and install Visual Studio Code with the REST Client extension
    • Downloading Visual Studio Code and using the REST Client extension is out of scope of this document
  • Create a new text file containing the sample code above, with a .http extension.  For example: pa_jobs.http
  • Open the .http file created with Visual Studio Code
  • Update the @host, @tenant, @tm1db and @apikey parameters accordingly
    • See the following to learn about API Keys in PA Workspace: 
      https://cloud.ibm.com/docs/planning-analytics?topic=planning-analytics-api__key_based_authentication
  • Assuming the REST Client extension has been installed correctly, there should be a Send Request text button available before each request (GET / POST)
  • Click Send Request for @name Authentication.  If successful, you should see an output that includes the response headers as well as some information related to the authenticated user
    image-20240909130336-1
  • Click Send Request for @name getJobs.  If successful, you should see an output that includes the response headers as well as a JSON output of all Jobs running on the database
    image-20240909130925-2
  • To cancel a job, populate @jobId with the ID of a job you wish to cancel (from the output generated above).  Click Send Request for @name cancelJob.  If successful, you will received an empty response indicating the HTTP status code: 204 No Content
    image-20240909131324-3

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSEAI8G","label":"Planning Analytics as a Service"},"ARM Category":[{"code":"a8m3p000000GoaGAAS","label":"Planning Analytics-\u003EPlanning Analytics as a Service Specific"}],"ARM Case Number":"TS017073208","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Document Information

Modified date:
09 September 2024

UID

ibm17167840