Reputation: 1089
How can I access the API related information like API Properties (defined in publisher) in the WSO2 Custom handler ?
Upvotes: 1
Views: 424
Reputation: 148
As I can see handler/mediator can have access to api properties via local registry
When defined in xml configuration it can be like this
<sequence name="custom-sequence" xmlns="http://ws.apache.org/ns/synapse">
<log level="custom">
<property
name="prop"
expression="get-property('registry',
fn:concat(
'gov:/apimgt/applicationdata/provider/',
$ctx:api.ut.apiPublisher, '/',
$ctx:api.ut.api, '/',
$ctx:api.ut.version, '/',
'api@api_meta.my_property'
))" />
</log>
</sequence>
Also when using property with devportal visibility enabled, then you have to access it via name ended with __display
for example api_meta.my_property__display
Upvotes: 0
Reputation: 1837
Refer the below code. It will print all the messagecontext property key set and their values.
Set propertySet = context.getPropertyKeySet();
for (Object propertyKey : propertySet) {
log.info("Key: " + propertyKey.toString() + "| value: "
+ context.getProperty(propertyKey.toString()));
}
Also refer this
Upvotes: 1
Reputation: 2209
You can use message context object to access API information:
messageContext.getProperty("api.ut.HTTP_METHOD")
Refer sample for more info.
Upvotes: 0