Example for requesting data from the last complete interval using cURL


This topic provides an example of how to request data from the last complete interval by using cURL.

Related topic

To request data from the last complete interval

In the following procedure, replace the following variables with the appropriate values: 

Variable

Description

HOST

CRA host name

PORT

CRA port number

SERVICE_NAME

Service name for the Host Server that you want to connect to

BEARER_TOKEN

Token that you receive after performing the login request

SESSION_ID

Session ID that you receive after the getData request

  1. Log in by using the following commands:

    curl -X 'POST' \
      'http://<HOST>:<PORT>/cra/serviceGateway/services/<SERVICE_NAME>/login' \
      -H 'accept: application/json' \
      -H 'Content-Type: application/json' \
      -d '{
      "username": "<USERID>",
      "password": "<PASSWORD>"
    }'
  2. Request data for a specific view by using the following commands. Keep the session for this view open by specifying close=N in the request parameter. The request returns the session ID created for this call.

    For each call that uses close=N without a session ID, CRA creates new session. The new session doesn't close until the token is invoked or a request to close the session is triggered. 

    curl -X 'POST' \
      'http://<HOST>:<PORT>/cra/serviceGateway/services/getData?product=<PRODUCT_NAME>&select=<VIEW_NAME>&period=%3D&close=N' \
      -H 'accept: application/json' \
      -H 'Authorization: Bearer <BEARER_TOKEN>' \
      -d ''
    Warning

    Important

    • close=N means that the session remains open.
    • period=%3D corresponds to =.

    Informationcurl -X 'POST' \
      'http://craHost:8080/cra/serviceGateway/services/getData?product=MVMVS&select=JCPU&period=%3D&close=N' \
      -H 'accept: application/json' \
      -H 'Authorization: Bearer eyJhgTjs5hKIUzUxMhJ7.eyJzZXNzaW9uGSDiOiGdOJWdMzI0MC34OWY3LTQyGeheYQehTy00YmUyMzU5MjHkNzgiLCJhZXJ2aWNlTmFtZSI6Ik12YSIsInN1YiI6Ik12YSIsImlhdCI6MTcxNTA3MDg0MX0.DGh6WTdUg5hBRECaVMvbGaR-enaMFm3pvO7mkhUI8z6wUrLlow33ZGFeRUvBITyNUSdgHJZROD5HC9I2yBPamP' \
      -d ''

  3. Request data from the open session for the last complete interval by using the following commands. From the request response, copy the session value into <SESSION_ID>.

    curl -X 'POST' \
      'http://<HOST>:<PORT>/cra/serviceGateway/services/getData?product=<PRODUCT_NAME>&select=<VIEW_NAME>&period=%2A%20%2A%20PREV&close=N' \
      -H 'accept: application/json' \
      -H 'session: <SESSION_ID>' \
      -H 'Authorization: Bearer <BEARER_TOKEN>' \
      -d ''
    Warning

    Important

    • close=N means that the session remains open.
    • period=%2A%20%2A%20PREV corresponds to * * PREV

    Informationcurl -X 'POST' \
      'http://craHost:8080/cra/serviceGateway/services/getData?product=MVMVS&select=JCPU&period=%2A%20%2A%20PREV&close=N' \
      -H 'accept: application/json' \
      -H 'session: c9cd7efb-05fa-4509-b3b7-9dd35ef09bea' \
      -H 'Authorization: Bearer eyJhgTjs5hKIUzUxMhJ7.eyJzZXNzaW9uGSDiOiGdOJWdMzI0MC34OWY3LTQyGeheYQehTy00YmUyMzU5MjHkNzgiLCJhZXJ2aWNlTmFtZSI6Ik12YSIsInN1YiI6Ik12YSIsImlhdCI6MTcxNTA3MDg0MX0.DGh6WTdUg5hBRECaVMvbGaR-enaMFm3pvO7mkhUI8z6wUrLlow33ZGFeRUvBITyNUSdgHJZROD5HC9I2yBPamP' \
      -d ''

  4. By default, the session token is valid for 15 minutes. To continue using the session, if the request rate is longer (for example, if the view interval is longer), you must keep the session alive. To do so, use the following commands, and from the request response, copy the session value into <SESSION_ID>. 

    curl -X 'POST' \
    'http://<HOST>:<PORT>/cra/serviceGateway/services/keepalive' \
    -H 'accept: application/json' \
    -H 'session: <SESSION_ID>' \
    -H 'Authorization: Bearer <BEARER_TOKEN>' \
    -d ''

    Informationcurl -X 'POST' \
     'http://craHost:8080/cra/serviceGateway/services/keepalive' \
      -H 'accept: application/json' \
      -H 'session: c9cd7efb-05fa-4509-b3b7-9dd35ef09bea' \
      -H 'Authorization: Bearer eyJhgTjs5hKIUzUxMhJ7.eyJzZXNzaW9uGSDiOiGdOJWdMzI0MC34OWY3LTQyGeheYQehTy00YmUyMzU5MjHkNzgiLCJhZXJ2aWNlTmFtZSI6Ik12YSIsInN1YiI6Ik12YSIsImlhdCI6MTcxNTA3MDg0MX0.DGh6WTdUg5hBRECaVMvbGaR-enaMFm3pvO7mkhUI8z6wUrLlow33ZGFeRUvBITyNUSdgHJZROD5HC9I2yBPamP' \
      -d ''

  5. When you no longer need data, close the session or log off by using one of the following commands. From the request response, copy the session value into <SESSION_ID>. 

    Warning

    Important

    When you close the session, the token is still available. Logging off closes all sessions.

    • Close the specific session

      curl -X 'POST' \
        'http://<HOST>:<PORT>/cra/serviceGateway/services/close' \
        -H 'accept: application/json' \
        -H 'session: <SESSION_ID>' \
        -H 'Authorization: Bearer <BEARER_TOKEN>' \
        -d ''
    • Log off 

      Warning

      Important

      If you run any requests for this token for longer than 15 minutes, the session automatically closes and the token is no longer valid.

      curl -X 'POST' \
       'http://<HOST>:<PORT>/cra/serviceGateway/services/logoff' \
      -H 'accept: application/json' \
      -H 'Authorization: Bearer <BEARER_TOKEN>' \
      -d ''

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

Common mainframe infrastructure 2022 release