API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Migration from apim module to context

    Posted Thu June 01, 2023 07:18 AM

    So right now, we are migrating from using apim module to context, but I can see we have two issues.

    I. What is the alternative of apim.getError()? From what I understand, I think the two context variables error.name and error.message are equivalent to name and message returning from apim.getError(). But what about policyTitle and status?

    {
      "name": "OperationError",
      "message": "This is a thrown Operation Error",
      "policyTitle": "Throw Operation Error",
      "status": {
        "code": "500",
        "reason": "Internal Server Error"
      }
    }

    II. If I have a JS script that exists in DataPower API Gateway's local directory, and I only load it in a GatewayScript. The script works perfectly fine with apim module but cannot identify "context" when being used instead. So how to use context in this scenario? (Without passing it to the script)



    ------------------------------
    Mohamed Alkhaligy
    ------------------------------


  • 2.  RE: Migration from apim module to context

    Posted Thu June 01, 2023 10:34 AM

    Hi Mohamed,
    context.get('error') is the equalivant to apim.getError().  Using the GatewayScript debugger in a catch block gatewayscript policy you can see the error object which would include the status and policy Title.

    (debug) p error
    {
      name: 'JavaScriptError',
      message: 'Internal Error',
      status: { code: 500, reason: 'Internal Server Error' },
      policyTitle: 'gatewayscript'
    }
    

    As for your second question, nothing is currently documented that would allow this. Most probably this would need to be a request for enhancement.
    Regards,

    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------