Not able to extract response dynamic header value from target response

from target response header I am getting the variable named "Tr-ui" from the target. But I am not able to extract that variable using the extract variable policy. Value of that variable will be JSON.

Below is the configuration. But I am not able to see the extra header in trace itself

<ExtractVariables name="ExtractVariables-1"> <Source>response</Source> <Header name="Tr-ui"> <Pattern ignoreCase="true">{extraHeaderValue}</Pattern> </Header> <VariablePrefix>targetHeader</VariablePrefix> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </ExtractVariables>

0 8 241
8 REPLIES 8

Can you please post your trace?

Are you able to see the header in the backend response variable?

yes I am able to see in target response. But it is not showing in extract policy output. In extract variable policy, under the variables section NOTHING Is showing. i mean the targetHeader.extraHeaderValue

I am also having the same issue, could you please share how you fix this issue.

Not applicable

You can directly try the variable as response.header.Tr-ui

Please check this.

My requirement is to extract the content-range from the response header, from the target i recevied as below

<ResponseMessage> <Headers> <Header name="Connection">keep-alive</Header> <Header name="Content-Length">569</Header> <Header name="content-range">count 1-1/1</Header> <Header name="Content-Type">application/json;charset=UTF-8</Header> <Header name="Date">Tue, 20 Oct 2020 22:17:04 GMT</Header> <Header name="Server">nginx</Header> <Header name="Strict-Transport-Security">max-age=15768000; includeSubDomains</Header> <Header name="x-vcap-request-id">10160b61-080c-4c00-6aa4-622b1884f36a</Header> </Headers>

i tried below in the assign policy.

<Set> <Headers> <Header name="content-range">{response.header.content-range}</Headers> </Set>

I tried with extract variable also,

<Header name="Content-Range"> <Pattern ignoreCase="true">{content-range}</Pattern> </Header> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <Source clearPayload="false">response</Source>

but both are not working.

Not applicable

You have to extract using extract variable policy xpath not using header.

Your source will be the header, and using xpath XML extraction you have to extract the value.

could you please help with the Xpath and extract variable syntex is correct or not

<Header name="Content-Range"> <Path ignoreCase="true">/ResponseMessage/Headers/*/{content-range}</Path> </Header>

Input Header:

<ResponseMessage>

<Headers>

Header name="Connection">keep-alive</Header>

<Header name="Content-Length">569</Header>

<Header name="content-range">count 1-1/1</Header>

<Header name="Content-Type">application/json;charset=UTF-8</Header>

<Header name="Date">Tue, 20 Oct 2020 22:17:04 GMT</Header>

<Headers>

Not applicable

use the below code and you will get the value you want in the variable content-range. It should be attached in the response.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1">
    <DisplayName>Extract Variables-1</DisplayName>
    <Properties/>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <Source clearPayload="false">response</Source>
    <XMLPayload stopPayloadProcessing="false">
        <Namespaces/>
        <Variable name="content-range">
            <XPath>//ResponseMessage/Headers/Header[3]</XPath>
        </Variable>
    </XMLPayload>
</ExtractVariables>