Cloud Pak for Business Automation

 View Only
  • 1.  Integrate Postman or External REST API with IBM Cloud Pak for Business Automation Workflow

    Posted Mon August 21, 2023 10:44 AM

    I have used Workflow process API and REST API Tester to get the process data and it is working.

    Response body:

    {
      "id": "2072.3526",
      "model": "IBM Process",
      "container": "IBMBAWU",
      "container_name": "IBM BAW(U)",
      "version": "db9d221e-64db-4441-98a7-6ea321509bad",
      "state": "stopped",
      "creation_time": "2023-08-21T04:38:14.444Z",
      "due_date": "2023-08-21T12:38:14.389Z",
      "input": [],
      "output": [],
      "internal": [
        {
          "name": "PIVariable",
          "data": {
            "Address": "madipakkam",
            "FirstName": "Rithik ",
            "DOB": "2023-05-15T18:30:00.000Z",
            "@metadata": {
              "dirty": false,
              "rootVersionContextID": "2064.4e5eb46d-7fb9-4e80-8ca9-a0e8b332f4fb",
              "shared": false,
              "invalid": false,
              "className": "Info",
              "objectID": "91e0d1f4-64fa-4175-9299-dfec6d619520-390077-1692592797546",
              "contentObject": false
            },
            "LastName": "R",
            "PanNo": "2343EMWE23"
          }
        },
        {
          "name": "LeaveApprovalStatus",
          "data": "Your Leave has been approved by PM"
        },
        {
          "name": "LeaveInfo",
          "data": {
            "empId": 123,
            "NoOfDays": 1,
            "LeaveType": "Sick Leave",
            "@metadata": {
              "dirty": false,
              "rootVersionContextID": "2064.db9d221e-64db-4441-98a7-6ea321509badT",
              "shared": false,
              "invalid": false,
              "className": "BOL",
              "objectID": "91e0d1f4-64fa-4175-9299-dfec6d619520-390077-1692592797547",
              "contentObject": false
            },
            "dep": "43445"
          }
        },
        {
          "name": "PMApproval",
          "data": true
        }
      ],
      "modification_time": "2023-08-21T04:39:58.034Z",
      "name": "IBM Process:3526",
      "branch_name": "Main"
    }


    Now I am trying to get the data from external tool like Postman or using request library in python, I am having trouble in authentication.

    I would really appreciate if someone gave me a step by step instruction to achieve this task.
    Contact : +91 - 9566084103
    Email: krishnanrithik98@gmail.com



    ------------------------------
    Rithik R
    ------------------------------


  • 2.  RE: Integrate Postman or External REST API with IBM Cloud Pak for Business Automation Workflow

    Posted Tue August 22, 2023 03:56 AM
    Edited by Michael Kirchner Tue August 22, 2023 03:56 AM

    Hi Rithik,

    did you provide a CSRF token when calling the REST API?

    https://www.ibm.com/docs/en/baw/23.x?topic=apis-preventing-cross-site-request-forgery

    In essence, in a first step you need to call the login endpoint (/bpm/system/login) which will send the CSRF token as response. This token must be provided as as BPMCSRFToken header when calling any other downstream REST API endpoints.

    Hope this helps!

    Best regards,
    Michael



    ------------------------------
    Michael Kirchner
    Sr. Business Automation Partner Technical Specialist
    IBM Technology
    Germany
    ------------------------------



  • 3.  RE: Integrate Postman or External REST API with IBM Cloud Pak for Business Automation Workflow

    Posted Wed August 23, 2023 06:10 AM

    Hi @Rithik R,

    you sent me a private message that you get the following response when calling the system/login REST API:

    <head>
    <meta charset="UTF-8">
    </head>
    <body>
    <script>
    // Redirecting to login page, keeping URL parameters and hash
    window.location.replace("./auth/index.jsp" + window.location.search + window.location.hash);
    </script>
    </body>
    </html>
    
    Based on the URL you are using, it seems that you are working with BAW as a Service and this is the expected behavior when you do not provide the correct credentials to authenticate the REST call.
    In any case, when calling the BAW REST API to generate the CSRF token, you'll have to authenticate first. If you call from rich client such as Postman, you typically set the authentication option in postman to use basic auth and then you provide username and password in the basic auth config dialog in Postman. 
    Postman basic auth
    If you are using BAW aaS, you will not be able to use your regular user credentials for basic authentication but you'll have to ask your instance admin to provide you with a functional user ID which has the appropriate permissions on the instance you want to work with.
    If you are using the correct fid user and the proper password, you should be able to call the system/login method. In the body of the call you must provide the requested parameter according to the documentation, e.g. 
    {
      "refresh_groups": true,
      "requested_lifetime": 7200
    }'

    As a result you should get a response with the CSRF token which you need to provide with any subsequent call.
    Hope this helps!
    Best regards,
    Michael


    ------------------------------
    Michael Kirchner
    Sr. Automation Partner Technical Specialist
    IBM Technology
    Germany
    ------------------------------



  • 4.  RE: Integrate Postman or External REST API with IBM Cloud Pak for Business Automation Workflow

    Posted Wed August 23, 2023 07:19 AM

    I am using IBM Cloud Pak for Business Automation in Free Trial. If I ask the instance admin for the Function ID will they give it to me and how to contact the instance admin.



    ------------------------------
    Rithik R
    ------------------------------



  • 5.  RE: Integrate Postman or External REST API with IBM Cloud Pak for Business Automation Workflow

    Posted Wed August 23, 2023 08:31 AM

    Good question.
    Have you requested the trial or are you using and instance which another person requested?

    If you requested the instance, you may see the  "Administer Subscription" entry in the main hamburger menu:

    If you have access to the menu, you create the functional ID from there (called a service user).
    Do you have access to the  "Administer Subscription" menu?
    Best regards,
    Michael


    ------------------------------
    Michael Kirchner
    Sr. Automation Partner Technical Specialist
    IBM Technology
    Germany
    ------------------------------



  • 6.  RE: Integrate Postman or External REST API with IBM Cloud Pak for Business Automation Workflow

    Posted Fri August 25, 2023 01:31 PM

    Hi @Rithik R,

    I  checked with the DevOps team. Unfortunately adding service users is not exposed for the BAW aaS trial instance and thus you'll not be able to call your workflow via REST from an external application.

    Do you have a particular use case in mind you want to test?

    Best regards,

    Michael



    ------------------------------
    Michael Kirchner
    Sr. Automation Partner Technical Specialist
    IBM Technology
    Germany
    ------------------------------