Skip to content

Instantly share code, notes, and snippets.

@gszr
Created August 6, 2025 15:19
Show Gist options
  • Save gszr/4f6acddfc2c70366e519147c3423c7f6 to your computer and use it in GitHub Desktop.
Save gszr/4f6acddfc2c70366e519147c3423c7f6 to your computer and use it in GitHub Desktop.
Callout body via Lua code
{
"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