Thank you for details .But we have requestHeader in the payload which we are referring after invoke .we want to route message base on condition in switch . we are using request.body.requestHeader.echo ='true' which is not working and please tell me how to use function
Original Message:
Sent: Mon February 21, 2022 10:01 AM
From: Steve Linn
Subject: how to refer payloads in switch policy
Hi Santhoshkumar,
I believe the [-1] is your issue. I also used $queryParameter instead of $urlParameter. The purpose of the $urlParameter is to simply provide the value for the named parameter which could be either a query or path parameter, so it should still work, but $queryParameter only looks at query parameters. I'll attach my simple test case yaml where I have a query parameter named "echo" and the switch is $queryParameter('echo') = "true"
and it works as I'd expect. The echo query parameter not provided or not "true" takes me to the otherwise clause, but "true" passes the condition. The other part of your condition "request.body.requestHeader.echoBack" is also incorrect if you're trying to check for a request header in addition to the query parameters. Use "request.headers.echoBack = "true" in that case. My sample checks for both now and is also working $queryParameter('echo') = 'true' or request.headers.echo = 'true'
Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Mon February 21, 2022 09:18 AM
From: santhoshkumar surisetty
Subject: how to refer payloads in switch policy
Hi Steve,
sorry for the confusion . the storageType is added by us to verify what it returns as the request.body.requestHeader.echoback refrecnce is not working . we are still looking for the solution.
v5 condition
=======

v10 condition
============

------------------------------
santhoshkumar surisetty
Original Message:
Sent: Thu February 17, 2022 04:13 PM
From: Steve Linn
Subject: how to refer payloads in switch policy
Thanks Santhoshkumar,
I would be curious if you would post just the if/switch condition in your v5 switch that is being migrated to $storageType. I could try a quick recreate in the AMU while waiting for the PMR.
Regards,
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Wed February 16, 2022 11:12 AM
From: santhoshkumar surisetty
Subject: how to refer payloads in switch policy
Thank you Steve for Advise. i will open PMR regarding it
------------------------------
santhoshkumar surisetty
Original Message:
Sent: Wed February 16, 2022 08:33 AM
From: Steve Linn
Subject: how to refer payloads in switch policy
Hi Santhoshkumar,
$storageType per the API Connect documentation for jsonata functions of a switch should return one of "binary" | "json" | "stream" | "xml". See https://www.ibm.com/docs/en/api-connect/10.0.1.x?topic=switch-writing-condition-scripts-datapower-api-gateway. I don't see $storageType in the current AMU code base, but that's not to say it wasn't there in AMU tool 10.0.3 -r2 version and been removed with recent revisions. What was your v5 switch condition that produced this resulting switch condition in the v10 api? Investigation of this would be best if you were to open a PMR for this. Please provide your v5 API yaml file and the resulting v10 API Gateway API yaml file with the issue and any AMU logs if you still have them. As for your question "do we need to rewrite it for all APIs , if we have similar conditions." the AMU is a migration tool meant to be a one time usage tool. Your options would be to fix any failing API or assuming this is a defect in the AMU, rerun the v5 to v10 migration when a fix is available. I understand that isn't the most desired answer, hopefully what produced this is isolated to a particular type of v5 condition that doesn't impact a large number of APIs.
Regards,
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Tue February 15, 2022 10:27 AM
From: santhoshkumar surisetty
Subject: how to refer payloads in switch policy
thank you for details . but we migrated apis from v5 to v10 by using AMU tool 10.0.3 -r2 version . the conditions in switch are not working . as they are getting converted to ($storageType(request.body.PolicyTransaction.ActionName) = "valuationAssignPolicyNumber"). do we need to rewrite it for all apis , if we have similar conditons.

------------------------------
santhoshkumar surisetty
Original Message:
Sent: Tue February 15, 2022 09:50 AM
From: Steve Linn
Subject: how to refer payloads in switch policy
Hi Santhoshkumar,
When you say "element in the request message" is your input XML or JSON? "Element" to me says XML. You'll first need to start off your assembly with a parse policy. That will take the raw text in the request message and will parse it into either an XML DOM or JSON object depending upon what your payload is. The parse of the request will be stored in the context "message" so then your switch condition would be
message.body.parent.child.element = '1'
That should work for JSON and for XML if your XML has no namespaces. If your XML does have a namespace or if you need to test against an XML attribute, then you'll need to use the $xpath function, for example
$xpath(message.body, '/*[@local-name() = 'parent']/*[@local-name() = 'child']/*[@local-name() = 'element'']) = 1
Regards,
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Mon February 14, 2022 04:18 PM
From: santhoshkumar surisetty
Subject: how to refer payloads in switch policy
Hi ,
i need to route request to backend based on content of element in the request messages . could you please tell me how to do in switch policy in apiconnect v10. i could not find any examples in the below reference link.
https://www.ibm.com/docs/en/api-connect/10.0.1.x?topic=switch-using-policy-condition-editor
------------------------------
santhoshkumar surisetty
------------------------------