How to create a custom error that returns the contents of the body from a POST method when a 400 " Server cannot read malformed syntax"

Not applicable
curl -X POST -H "Authorization: Basic 12345" -H "Cache-Control: no-cache"  -H "Content-Type: application/x-www-form-urlencoded" -d 'grant_type=refresh_token&refresh_token=12345' "https://apidev.oppenheimerfunds.com/oauth2/v2/token"

I get an error when the refresh_token is not in the correct format. A 400 BAD REQUEST "Server unable to read malformed syntax".

How do I write a custom error when receiving this 400 so that apigee returns the refresh_token to the client?

Thanks!

0 1 116
1 REPLY 1

This might work

<AssignMessage name='AM-1'>
  <AssignTo createNew='false' transport='http' type='response'></AssignTo>
  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
  <Set>
  <Payload contentType='application/json'>{
  "bad_refresh_token" : "{request.formparam.refresh_token}"
}
<StatusCode>400</StatusCode>
    <ReasonPhrase>Bad Request</ReasonPhrase>
  </Set>
</AssignMessage>

If the target is returning a 400,...You will need to make sure that policy ^^ runs in the fault rules....