Assign Message Policy Set Flow Variable - Target Side - Read - Error

Using AssignMessage policy I am creating a flow variable by copying path variable (ex., /{id}). Now when I am referencing this flow variable on target side I am seeing the value as 'com.apigee.flow.message.MessageImpl@3f9b7355'. Could someone please help?

0 5 2,013
5 REPLIES 5

@Karthick Vankayala , Welcome to Apigee Community.

Please post Assign Message policy xml details & how you are retrieving the value on target side to better understand your issue ?

@Anil Sagar Thanks for prompt response. Here are the details, the actual path is /v1/location/{id}

1. Save ID (Assign Message Policy)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="SaveLocationId"> <DisplayName>SaveLocationId</DisplayName> <Properties/> <Copy source="request"> <Path>{id}</Path> </Copy> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="true" transport="http" type="request">kv.Id</AssignTo> </AssignMessage>

2. Script policy

context.setVariable("target.copy.pathsuffix", false); var targetserver = context.getVariable("target.url"); var dynamiccontextpath = context.getVariable("kv.Id"); if(dynamiccontextpath !== null) { var targeturl = targetserver + '/' + dynamiccontextpath; context.setVariable("target.url", targeturl); }

@Karthick Vankayala , Ideally, you need to use Extract Variables policy to extract variable from path. Any reason why you are using Assign Message Policy ?

@Anil Sagar That's true, I used Extract Variables policy which worked, but I was just trying out different options and found this error.

Actually, I used Assign Message policy to implement my other use case and when I got this requirement I thought of fitting this one in the existing policy to reduce response time by few milli-secs (Not sure if it works that way).

@Karthick Vankayala ,

Assign Message Policy doesn't support extracting path components by patterns. It copies entire path to another variable specified in AssignTo element in AssignMessagePolicy. That's the reason it didn't work for you. It's by design.

As you have mentioned in above comment, Extract Variable Policy should be used to solve your use case. Hope it helps