Hi, you can use javascript policy.And in that you can use sth like
var reqPayload = JSON.parse(context.getVariable('request.content'));
var flag=reqPayload.hasOwnProperty('name');
print(flag);
and use the flag accordingly. hasOwnProperty() will check if the property ānameā exists or not in payload. If not then will return false otherwise true.
You can set continueOnError=ātrueā in your Extract-valid-until-date policy. The extract error will not be raised. In the subsequent policy step definition, you can add a condtion to validate valid_until for NULL or whatever value you need & take appropriate action.
You can also achieve the same by using JS callout which @Vipul Agarwal has posted. I dont see much different either way except you can avoid a JS callout
@miloud , Ideally Extract Variable policy should work. JSON extraction is performed only when messageās Content-Type is application/json. Are you sure response contains Content-Type āapplication/jsonā ?
I know this is late for this is for anyone who faces issue. Use the extract policy mentioned in the question itself. Just add following tag in that policy.
If you use this tag, it will ignore it if itās not able to find that key in JSON. This is useful when we receive 200 status and error in the body and you want to convert 200 to actual error with 4xx/5xx status code.