I think I understand what you’re asking. In the API Proxy, after receiving the response from the target, You want to compare a parameter from the original client request, to a parameter in the target response. No problem.
What is the format of the target response? Let’s suppose it’s JSON. And let’s suppose you want to compare a queryparam from the request to a value in that json hash. Apigee makes available the queryparam for the inbound client request in a context variable named like request.queryparam.PARAMNAME . This context variable is available in the request flow, and also in the response flow. There’s no need to store anything in the KVM or do anything in particular to keep that state around. Apigee does that for you. So, to check whether the inbound parameter matches something from the response, you want a step attached in the response flow, with a condition like this:
<Condition>request.queryparam.shopname = SOMETHING_FROM_THE_RESPONSE</Condition>
Or you could do the logical inverse of that condition, with a NOT operator:
<Condition>NOT(request.queryparam.shopname = SOMETHING_FROM_THE_RESPONSE)</Condition>
But what is SOMETHING_FROM_THE_RESPONSE ? Apigee inserts the entire target response body into a context variable called response.content. But it is just a string, and there is no automatic setting of specific context variables corresponding to the fields in JSON body. To get the SOMETHING_FROM_THE_RESPONSE, you can use the ExtractVariables step. It might look like this:
<ExtractVariables name='EV-Shopname-from-Response'>
<Source>response</Source>
<VariablePrefix>extracted</VariablePrefix>
<JSONPayload>
<Variable name='shopname'>
<JSONPath>$.shopName</JSONPath>
</Variable>
</JSONPayload>
</ExtractVariables>
If the format of the response is not JSON, maybe it’s XML or something else, then you’d replace that ExtractVariables with a different ExtractVariables, or some other thing that parses the response and extracts the field of interest.
Attach that EV step somewhere in the Proxy Response flow. After that step executes, if there was a toplevel field named shopName in the JSON body, then you will have a variable named extracted.shopname in the message context. Which means you could do something like this in your flow:
<Response>
<Step>
<Name>EV-Shopname-from-Response</Name>
</Step>
<Step>
<Name>RF-Not-Found</Name>
<Condition>NOT(request.queryparam.shopname = extracted.shopname)</Condition>
</Step>
...
You may not need a RaiseFault there… you could use AssignMessage and set the status to 404. The difference is that RaiseFault interrupts further normal step processing, while AssignMessage will not. Also you may want another step in there, Conditioned on a test like extracted.shopname = null , to check if no shopname was in the response at all.
So it should be pretty easy, if I’m understanding the question correctly.
But I have to say, this is a little unusual. Normally, the target server will return 404 when 404 is appropriate. It’s odd for a proxy to receive a 200 from the target and then override it with 404 if something in the response doesn’t look right. I guess it would make sense to do this if the interface for the target is not very sensible, or if you’re transforming it in some way.
good luck.