cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Capture Response Body as Request Attribute (NGINX)

gary1024
Visitor

We have request on Nginx that always reply response 200 but need to look into response body to capture status of 'fail' or 'success'.

  },

  "response": {

    "statusCode": 200,

    "body": "{\"message\":null,\"responseData\":{\"accountList\":[{\"accountNo\":\"2491011751\",\"canAddNewLine\":true,\"msisdnList\":[]}],\"deviceAdvancePaymentWaive\":\"N\",\"ratePlanAdvancePaymentWaive\":\"Y\",\"lineDepositWaive\":\"Y\",\"newProductOfferId\":\"4062147\",\"deviceDAPAmount\":\"540\",\"orderAck\":\"Y\"},\"status\":\"fail\",\"timeStamp\":\"2023-02-14 01:37:05\",\"violations\":null}"

  }

}

 

However, looking at request attributes documentation does not really mention on this. Is there a way to capture this as an attribute?

 

Gary

1 REPLY 1

Romanenkov_Al3x
DynaMight Mentor
DynaMight Mentor

Hello Gary.

We often set a request attribute for capturing arguments\return value from classes and methods which work with body \ make body response on App server level (on a Java backend for example) In this situation.

With custom error rules you can set to mark requests which have 200 response code and request attribute - error: value as failed. 

Nginx in our situation is only balancer or web server to serve static files.

Regards,

Romanenkov Alex

DT_NGINX_ALL_WHITELISTED=1