Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.
This article explains about when to use what policy in routing.
It is assumed that readers of this article know how to setup policies on API Gateway.
Ah, you solved it already - this must be a forum post and not lost in the article comments.
KM
Kasi – I think I am clear on the difference between content- and context-based. I am looking for content-based (we’re using context-based in another API). Given this sample payload:
{ "abc" : "123x", "function" : "xyz", "foo" : "bar" }
I want to define a rule to route to specific targets based upon the value of say, $.function. Not dynamic–the value isn’t to be part of the URL. For example:
if $.function == “xyz” route to endpoint https://abc.com/foo/bar if $.function == “flippityfloop” route to endpoint https://southpark.com/marklar
Here is the properties pane of content-based routing in 10.5:
The documentation for this policy describes Payload Expression as “Specifies using the payload identifier to identify the client, extract the custom authentication credentials supplied in the request represented using the payload identifier, and verify the client’s identity.”
The documentation goes further to describe Expression Types and the JSONPath type: “Provide the Payload Expression that specifies the payload expression that the specified JSONPath expression type in the request has to be converted to. For example: $.name.id”
Those descriptions and the properties pane are exactly the same as those for “Identify and Authorize Application” used to extract a value that can then be matched with an application. As elaborated upon at webMethods.io API Gateway: Securing APIs using Payload Element
There, one defines how to extract the app ID value of interest from an arbitrary element in the payload. Then, assign values in the application config for the “Payload Identifier” identifier. Makes good sense there.
Content-based routing config does not seem to match the high-level description “You can route messages to different endpoints based on specific values that appear in the request message.”
What am I missing?
[Edit] I suspect what I’m missing is simply to use JSONPath filter operators although those are used to filter arrays. E.g. $.function == “xyz” as my example above. I’ll dig into that, but it would awesome if the docs and panel labels were a bit more clear…
[Edit2] Success! Using this expression did what I wanted. [?($.function==“xyz”)]
Rob, I think you have "content"and “context” mixed up.
The former is what you’re looking for with payload-based routing, whereas the latter is based on “metadata” variables (well beyond the identifiers available with the Identify & Authorize policy).
The use case example above doesn’t cover all the contextual variables that are supported. Else, if you’re already aware of all the supported contextual variables, then which additional ones do you think are missing and must be supported?
P.S - If I’m not following your requirement, can you elaborate further?
Examples of using these would be fantastic.
The “Content-based Routing” policy seems…very limited based upon the fields in the rule definition. Is this policy geared only to identify the calling application? If so, isn’t that redundant with the “Identify & Authorize Application” policy?
I’m trying to route to an end-point based upon the value of a field in the payload, regardless of the calling application. Based upon what I see, that does not seem to be possible – but hopefully I’m missing something not-so-obvious.
(Using on-prem API GW, not wM.io)