REST API - Different response structures

REST API - Different response structures

  

hi there,

My application consumes RESP API service and Outsystems has created the structure something like this:

{
    "responseCode": "200",
    "responseDesc": "Success",
    "content": {
        "name": "aaaa",
        "number": "1"

    }

}

Unfortunately, if the ResponseCode:"400", the REST producer return response like this that do not match the structure:

{
    "responseCode": "400",
    "responseDesc": "Not Success",
    "content": {
        "   "

    }

}

or

Unfortunately, if the ResponseCode:"200" and not found the data, the REST producer return response like this that do not match the structure:

{
    "responseCode": "200",
    "responseDesc": "Success",
    "content": null

}

My question is how to workaround this case usually?

Thank you and best regard,

I


Solution

Hi Putu,

You could implement an On After Response that scrubs the data in such a way the Platform can handle it (most likely remove invalid "content" stuff).

Solution