DataPower

 View Only
Expand all | Collapse all

Datapower mpgw error response needed in json format

  • 1.  Datapower mpgw error response needed in json format

    Posted 10 days ago

    Hi All,

    In Datapower v10.5, we created Multi Gateway protocol to accept JSON request and we are passing the same request to downstream system for further process. When we are getting any invalid JSON format, by default DataPower is replying the fault error/string in XML format, But we are excepting the fault error/string in JSON format.

    We have tried with transform using xslt but it is not working 

    Can anyone help us if any other option to create error response in json format?

    Thanks

    Bhanu Prakash



    ------------------------------
    Bhanu Prakash Desakuru
    ------------------------------


  • 2.  RE: Datapower mpgw error response needed in json format

    Posted 10 days ago

    Hi,
    Use GatewayScript to create the error message.
    Something like:

    //Load the header-metadata API
    var hm = require('header-metadata');
    //set header
    hm.current.set("Content-Type", "application/json");
    //Load service metadata
    var sm = require('service-metadata');
    var errorString = sm.getVar('var://service/error-message');
    var jsonObj= {
    "statusCode":500, 
    "StatusDescription" : "Internal Server Error",
    "message" : errorString
    } ;
    session.output.write(jsonObj);


    ------------------------------
    Joacim Dahlblom
    ------------------------------