Monday, May 22, 2017

#573 Oracle API Platform CS --> Groovy Scripting in the Logging Policy

According to the official docs -

You can use Groovy notation to access dynamic contents like headers, query
parameters, payloads and some context properties in specific policies.

These policies include:
• Method Mapping
• Service Callout
• Logging
• Redaction
• Groovy Script

So now to a simple example -

The REST request is as follows -

Let's log the client value

and write it to the following logfile -

This file will be created in the /customlogs directory in the following
path -


My gateway node is called gateway1.

Btw. The 4 variables for addressing values are -

- headers
- payload
- queries
- msgProperties

Ok, let''s test it out -

I re-deploy the api to the gateway.

I test via Postman - the same test as shown previously.

I go to my Gateway and look in the /customlogs directory -

and there it is.

I check out the contents -

So what's the issue here?

Yes, that's it - I should be referencing it via the queries variable.

I do the necessary and re-test.

A more in-depth article on Groovy scripting in APIP CS is available here
It is from the Oracle A-Team.

No comments: