Layer7 API Management

  • 1.  Customize #OTK Fail with error message

    Posted Mar 28, 2018 10:03 AM

    I have a requirement to customize OTK error message.

    OTK Version : 4.1

    Gateway version : 9.2

     

    e.g.

    1. OTK error message default error message format is :

    {
    "error":"invalid_request",
    "error_description":"Custom error description"
    }

       2. Expecting OTK error message error message format is :

    {
    "error": {
    "status": "400",
    "errors": [
    {
    "fields": "["invalid_request"]",
    "key": "error. missingDuplicate.parameters"
    }
    ]
    },
    "data": {}
    }

    Please have a look at below approach and let me know how to achieve it.

    Approach 1 : Override message creation in "OTK Fail with error message"

    Approach 2 : Capture error message in "Global Message completed" and modify format

    Approach 3 : Able to modify error message for each status code in customizations/#OTK Fail with error message

    Challenges :

    1. challenges in Approach 1 : how to disable "OTK Cache Store" and override error.msg context variable.
    2. challenges in Approach 2 : Unable to get error message as part of ${response.mainpart} or ${resp.mainpart} and unable to expose as  "Export Variables from Fragment" in customizations/#OTK Fail with error message.
    3. challenges in Approach 3 : Have to override all error code policy assertions, which is not a good practice.

     

    I failed to achieve even though, was trying to modify "#OTK Cache Look Up Customization / "#OTK Cache Store Customization" . Please share your inputs.



  • 2.  Re: Customize #OTK Fail with error message

    Broadcom Employee
    Posted Apr 02, 2018 10:41 AM

    I would not recommend Approach 1  and modifying OTK Fail with error message directly. To  disable caching of error messages completely you can copy the "isCached" context variable to the top of "#OTK Fail with error message" and set its value to true which will cause cache logic you show at line 255 to not cache error messages.

     

    Approach 3 is the recommended approach and will persist upgrades. 



  • 3.  Re: Customize #OTK Fail with error message

    Posted Apr 04, 2018 06:52 AM

    Thank you Stern for your valuable inputs,

     

    I am able to disable cache but unable to modify/customize error.msg. Is there any way to get ${error.msg} inside "#OTK Fail with error message" or "Global Message completed"?



  • 4.  Re: Customize #OTK Fail with error message

    Broadcom Employee
    Posted Apr 04, 2018 09:54 AM

    ${error.msg} is set further down in the "OTK Fail with error message" assertion. TO override all OOB error messages you would need to copy all the error handling branches to "#OTK Fail with error message" and modify them accordingly. 

     

    I would avoid using "Global Message completed" for this.