Solved Solved

Header,Raise fault

gopaldurgoji
Participant III

During a call Im adding a header- "Required-ID" in postman.

I want to raise a fault if the header name is wrong , for example - if the header name is like requiredid,Requiredid etc... I want the header name to be Required-ID only.

How can I raise the fault?

Solved Solved
0 1 398
1 ACCEPTED SOLUTION
Solved Solved

isaias_arellano
Participant III

Hi @Gopal D J,

HTTP headers are case insensitive, so the condition in this case to trigger you Raise Fault should be

<Condition> request.header.Required-ID != null </Condition>

Nevertheless if you still need to be case sensitive then one approach will be some javascript code to verify the presence of the header, like:

var found = false;
for (var name in context.getVariable('request.headers.names').toArray()) {
    if ( name === 'Required-ID' ) {
        found = true;
        break;
     }
}

context.setVariable('_required_id', found);

Then in your flow add a condition to your RF policy as:

<Step>
    <Name>RF-Missing-Required-ID</Name>
    <Condition> _required_id == false </Condition>
</Step>

Hope it helps.

View solution in original post

Solved Solved
0 0 0
1 REPLY 1
Solved Solved

isaias_arellano
Participant III

Hi @Gopal D J,

HTTP headers are case insensitive, so the condition in this case to trigger you Raise Fault should be

<Condition> request.header.Required-ID != null </Condition>

Nevertheless if you still need to be case sensitive then one approach will be some javascript code to verify the presence of the header, like:

var found = false;
for (var name in context.getVariable('request.headers.names').toArray()) {
    if ( name === 'Required-ID' ) {
        found = true;
        break;
     }
}

context.setVariable('_required_id', found);

Then in your flow add a condition to your RF policy as:

<Step>
    <Name>RF-Missing-Required-ID</Name>
    <Condition> _required_id == false </Condition>
</Step>

Hope it helps.

View solution in original post

Solved Solved
0 0 1
Top Labels in this Space
Top Solution Authors