Register today for Oracle CloudWorld. October 17th - 20th, Las Vegas

Register now

Hillel Cooperman, Senior VP of User Experience Design, has a message for you on Oracle CloudWorld

Watch now
Modify field JSON Payload Groovy — Cloud Customer Connect
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Modify field JSON Payload Groovy

Accepted answer
edited Aug 10, 2021 3:35PM in API Management 1 comment


Hi Gurus,

I am trying to modify one field of the JSON Payload I am receiving as an Input with a Groovy Policy.

For example, I receive this:


"field1": "value1",

"field2": "value2"


And I need to send this:


"field1": "value1",

"field2": "1234"



I've found this link:

def body = context.ApiRequest.getBody()
body.asJSONObject().put("field2", "1234")

def length = body.asString().length().toString()



but it is not working. Am I doing something worng?

Thanks in advance!




Howdy, Stranger!

Log In

To view full details, sign in.


Don't have an account? Click here to get started!