Extract Variable Policy not working

I am trying to extract variables of request payload using extract variable policy. below is the code I am using.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> EV-Payload true $.MillId $.Quantity request apigee

But the policy is not extracting values. Can anyone identify the error I made.

Thanks,

Hira

2 Likes

My payload is below

{
“MillId”: “98”,
“Quantity”: “1500”
}

1 Like

ExtractVariables with the JSONPayload optionwill work, only if the content-type is application/json .

If you have a text/plain content-type, then EV will ignore it and will not extract. Could that possibly be what you are seeing?

When I try your policy with a sample proxy, it works if the content-type is correct.

$ curl -i $apigee/ev-json-payload-test/t1 -H content-type:application/json -d '{ "MillId": "abcd", "Quantity" : "1500" }' 
HTTP/2 200 
content-type: application/json
content-length: 72
apiproxy: ev-json-payload-test r1
x-request-id: b36abf87-0021-47df-a1fd-f7cc5524fc01
date: Fri, 23 Feb 2024 17:33:36 GMT
via: 1.1 google, 1.1 google
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

{
    "status" : "ok",
    "MillId" : "abcd",
    "Quantity" : "1500"
}

$ curl -i $apigee/ev-json-payload-test/t1 -d '{ "MillId": "abcd", "Quantity" : "1500" }'                  
HTTP/2 200 
content-length: 64
content-type: application/json
apiproxy: ev-json-payload-test r1
x-request-id: 896f7d00-5e89-4e92-a369-06822bec1a45
date: Fri, 23 Feb 2024 17:33:47 GMT
via: 1.1 google, 1.1 google
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

{
    "status" : "ok",
    "MillId" : "",
    "Quantity" : ""
}
1 Like