BPM, Workflow, and Case

BPM, Workflow, and Case

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
  • 1.  Invoke BPMRESTRequest - parameter is missing all the time

    Posted Mon August 28, 2023 09:05 AM

    Hello!

    I am trying to call my service using BPMRESTrequest. This is what the swagger looks like:

    openapi: 3.0.1
    info:
      title: TEST
      version: 1.0.0
    servers:
      - url: 'https://test.com.:8400'
    paths:
      /system/bc/{userId}:
        get:
          summary: TEST
          operationId: getUserData
          parameters:
            - name: userId
              in: path
              required: true
              schema:
                type: string
          responses:
            '200':
              description: Successful response
              content:
                application/xml: {}
          security:
            - basicAuth: []
    components:
      securitySchemes:
        basicAuth:
          type: http
          scheme: basic
    

    I'm importing this swagger into BAW. I call the service test_service. Everything is done without error. Now I'm trying to call my service using JS:

    var request = new BPMRESTRequest();
    
    request.externalServiceName = "test_service";
    request.operationName = "getUserData";
    request.paramaters = {"userId": "123456789"};
    
    var response = tw.system.invokeREST(request);
    var content = response.content;
    
    tw.local.httpStatusCode = response.httpStatusCode;
    tw.local.response = response.content;
    

    And all the time I get the message: CWXSD1017E: The required parameter userId is missing.

    I tested this swagger in Postman and everything works fine. Please help because I'm going crazy with this IBM BAW product. 



    ------------------------------
    Lukas Davis
    ------------------------------


  • 2.  RE: Invoke BPMRESTRequest - parameter is missing all the time

    Posted Mon August 28, 2023 02:32 PM

    Hi Lukas,

    Your problem may be because the parameterized path is not specified/resolved. Your path is /system/bc/{userId}. Although, you are passing in the request parameter, that would only specify the query parameters. The base path would still be /system/bc/{userId}. Meaning your request would look like this:
    ... GET https://test.com:8400/system/bc/{userId}?userId=123456789. 

    The {userId} in the base path would still need to be substituted. Assuming that is the root cause, you can try one of the following two options:

    Option #1: Override endpoint address. Like so:

    var serverURL = "https://test.com:9400";
    var basePath = "/system/bc/{userId}" // Can be read from specs or from ENV var, etc.
    request.endpointAddress = serverURL + basePath.replace('{userId}', tw.local.userId);

    Option #2: The other option I can think of is specifying the request path and replace the parameter in it. Usually, this way is only necessary when operationId is not specified in the open API spec. But in your case you can skip specifying request.operationName and specify httpMethod and path instead. Something along these lines:

    var basePath = "/system/bc/{userId}" // Can be read from specs or from ENV var, etc.
    request.httpMethod = "GET";
    request.path = basePath.replace('{userId}', tw.local.userId);

    As a last resort, you can invoke an HTTP request using Java integration call. 

    PS: The use of the same parameter - userId in the path and in the query parameter seems redundant. So, if you can influence the API being called in this example, you might want to change the API and remove it from the path to make your life simpler. 

    PPS: In the specs you copy-pasted there is an additional dot "." after com in your servers > url. I'm sure that is not your problem just something to note and double check.

    paths:
      /system/bc/{userId}:


    ------------------------------
    Ajay Katre
    Salient Process
    ------------------------------



  • 3.  RE: Invoke BPMRESTRequest - parameter is missing all the time

    Posted Fri September 15, 2023 11:47 AM

    Hello Lukas,

    Looks like you are myspelling parameters

    var request = new BPMRESTRequest();
    
    request.externalServiceName = "test_service";
    request.operationName = "getUserData";
    request.parameters = {"userId": "123456789"};
    
    var response = tw.system.invokeREST(request);
    var content = response.content;
    
    tw.local.httpStatusCode = response.httpStatusCode;
    tw.local.response = response.content;

    Try this update.

    Best regards,

    Nicolas



    ------------------------------
    Nicolas Le Ralle
    ------------------------------