HI,
I am using Extract policy to extract the json request and need to assign using Assign message policy , but getting blank json o/p as below :
{ "comment" :"", "jokeid" : "", "commentor" : "" }
My Extract policy o/p is displaying correct as below :
{ "comment" :"XXXX", "jokeid" :3112, "commentor":"YYYYY" }
I need to assign this o/p using Assign Message Policy but getting blank values as shown above.
Extract Policy Code :
<ExtractVariables name="Extract-Comments"> <DisplayName>Extract Comments Post</DisplayName> <Properties/> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <JSONPayload> <Variable name="comment"> <JSONPath>$.comment</JSONPath> </Variable> <Variable name="commentor"> <JSONPath>$.commentor</JSONPath> </Variable> <Variable name="jokeid"> <JSONPath>$.jokeid</JSONPath> </Variable> </JSONPayload> <Source clearPayload="false">request</Source> </ExtractVariables>
Assign Message policy code :
<AssignMessage name="Assign-Comments"> <DisplayName>Assign Comments</DisplayName> <Set> <Payload contentType="application/json">{ "comment" :"{comment}", "jokeid" : "{jokeid}", "commentor" : "{commentor}" } </Payload> </Set> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="request"/> </AssignMessage>
Please suggest.
============================================================================
,
Add prefix in extract variable policy and then try accessing it in assign message poilicy using {prefixname}.{nameofthevariable}.
Try and let me know.
Thanks,KP
Thanks for the input , but same o/p even after adding the prefix also. It seems prefix is not mandatory to add.
@AJay Gupta, Update your assign message policy as below:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="true" enabled="true" name="Assign-Comments"> <DisplayName>Assign Comments</DisplayName> <FaultRules/> <Properties/> <Set> <Payload contentType="application/json" variableSuffix="#" variablePrefix="@"> { "comment" :"@comment#", "jokeid" : "@jokeid#", "commentor" : "@commentor#" } </Payload> </Set> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="request"/> </AssignMessage>
Hi Mohammed,
Thanks for taking time on the issue.I modified with changes suggested in Assign Message policy but still getting blank values as o/p , please see below the changes done :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="true" enabled="true" name="Assign-Comments">
<DisplayName>Assign Comments</DisplayName>
<FaultRules/>
<Properties/>
<Set>
<Payload contentType="application/json" variableSuffix="#" variablePrefix="@">
{ "comment" :"@comment#",
"jokeid" : "@jokeid#",
"commentor" : "@commentor#"
}
</Payload>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/> </AssignMessage>
Please help.
Regards,
Ajay
@AJay Gupta, Could you provide the current extract variable policy config here?
Just FYI, you do not need to set the variableSuffix and Prefix if you don't want to. This works:
<Set> <Payload contentType="application/json" >{ "comment" :"{comment}", "jokeid" : "{jokeid}", "commentor" : "{commentor}" } </Payload> </Set>
If anyone can help on the issue , it will be really helpful as its a show stopper for me.
Thanks in advance.
Regards,
Ajay.
Where are you placing your Assign message policy?
Use it on the Response flow to display as output.
Yes, I have the same question as @Barahalikar Siddharth . Can you show us the Proxy/Flow ? I want to see the order in which the ExtractVariables and AssignMessage are being executed.
I've built a working API proxy that .... does what I think you're trying to do. It works for me. See attached.
Invoke it like this:
curl -i https://ORG-ENV.apigee.net/ev-ajay-gupta/f1 \ -H content-type:application/json \ -d ' { "comment" : "hello", "commentor" : "dino", "jokeid": "123344" } '
@AJay Gupta, I have tried with Dino provided proxy bundle and it's working fine. Ensure you are sending the request JSON message in proper format.
@Mohammed :
@Dino
Thanks.
Able to get the values when hitting request from postman and able to get the json values in output.This resolves the issue for now.
@Ajay Gupta, Glad your issue is resolved. Click "Accept" below the answer that fully addressed your question.
User | Count |
---|---|
5 | |
2 | |
2 | |
1 | |
1 |