Created
August 6, 2025 15:19
-
-
Save gszr/4f6acddfc2c70366e519147c3423c7f6 to your computer and use it in GitHub Desktop.
Callout body via Lua code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "request-callout", | |
"config": { | |
"callouts": [ | |
{ | |
"name": "c1", | |
"request": { | |
"url": "https://httpbin.org/anything", | |
"method": "POST", | |
"body": { | |
"custom": {}, | |
"decode": false, | |
"forward": true | |
}, | |
"by_lua": "local body_json = '{\"id\": \"foobar\"}'; kong.ctx.shared.callouts.c1.request.params.body = body_json" | |
}, | |
"response": { | |
"body": { | |
"decode": true | |
}, | |
"by_lua": "kong.log.inspect(kong.ctx.shared.callouts.c1.response.body)" | |
} | |
} | |
], | |
"upstream": { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment