hi, can someone point me in the right direction? In my product, I can’t have OOTB Error messages since I’m connecting to newer/older existing systems with already present error codes/ messages.
(… and I really wish I don’t have to write API wrappers just to handle the error messages)
this is my problem.
-
I have an API that validates the OAuth access token.
-
it fails correctly when I pass an invalid key with this message
{
"fault": {
"faultstring": "Invalid Access Token",
"detail": {
"errorcode": "keymanagement.service.invalid_access_token"
}
}
}
- I have company standards on how the error message should be. so I need to catch this error and pass something that looks different.
I typed a FaultRules in my proxy
<FaultRules>
<FaultRule name="InvalidAccess_Token">
<Step>
<Name>InvalidAccess_Token</Name>
</Step>
<Condition>(fault.detail.errorcode = "keymanagement.service.invalid_access_token")</Condition>
</FaultRule>
</FaultRules>
I do that because I assume I can read from the original error message in this way fault.detail.errorcode
- I created a global policy not attached to a flow → InvalidAccess_Token
This is an Assign Message where I want to do different formatting
<AssignMessage async="false" continueOnError="false" enabled="true" name="InvalidAccess_Token">
<DisplayName>InvalidAccess_Token</DisplayName>
<Properties/>
<Set>
<Payload contentType="application/json">
{
"info": "operation failed"
}
</Payload>
<StatusCode>401</StatusCode>
<ReasonPhrase>Unauthorized</ReasonPhrase>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
questions.
- is this the way to go? I typed what i thought it was logical to me.