How to throw Exception with our pattern ?

the below error  I am getting now.

{
    "Errors": [
        "The request body is missing."
    ],
    "StatusCode": 400
}

but i want to customize to below error how to do that please help me.

{
    "statusCode": "400",
    "errorMessage": "The request body is missing",
    "errorCode": [
        "ERR_BODY_EMPTY"
    ]
}

Hi santhu MS,

You need to provide us more context to what you are doing, that seems JSON... are you exposing or consuming a REST API?

Please read Eduardo's guide on how to ask questions in the Forums, I'm sure it'll improve the benefit you get from this forum.



Solution

santhu MS wrote:

the below error  I am getting now.

{
    "Errors": [
        "The request body is missing."
    ],
    "StatusCode": 400
}

but i want to customize to below error how to do that please help me.

{
    "statusCode": "400",
    "errorMessage": "The request body is missing",
    "errorCode": [
        "ERR_BODY_EMPTY"
    ]
}

Agree with Jorge Martins, You should post a proper Question on Forum.

Perhaps what I understand, You want a specific Structure of JSON when a Response come with statusCode:400

You can achieve that via API onAfterRequest Action.


Solution