Request Transformer: http_method + add.body

Hello everyone.

I’m using kong community with the Request Transformer plugin. I want to transform a GET in Kong into a POST in my API. As a test, I’m using an Echo API that just returns the payload received. For the plugin configuration I used these values:

curl -X POST http://localhost:8001/apis/1ce6ba82-f8f6-4f0a-a8f3-187051a2b663/plugins \ --data "name=request-transformer" \ --data "config.http_method=post" \ --data "config.add.body=echo:echo"

The plugin is created accordingly, as GET in /plugins returns.

{ "created_at": 1523300420000, "config": { "remove": { "querystring": {}, "headers": {}, "body": {} }, "add": { "querystring": {}, "headers": {}, "body": [ "echo:echo" ] }, "http_method": "post", "append": { "querystring": {}, "headers": {}, "body": {} }, "replace": { "querystring": {}, "headers": {}, "body": {} }, "rename": { "querystring": {}, "headers": {}, "body": {} } }, "id": "41110bf3-e82e-415f-8a4b-7e393a0403fa", "name": "request-transformer", "api_id": "1ce6ba82-f8f6-4f0a-a8f3-187051a2b663", "enabled": true }

Although, my GET only return null. Is there something wrong ? Can’t I add a body since GET doesn’t have a payload ?

Any help would be appreciated.

Hi PFadel,have you solved this problem?

Hi,
I had the same issue trying to redirect a GET to a POST resulting in null bodies.
figured out, if I set the header to Content-Type:application/json it works.
Guess there were some checks on the Content-Type inside the transformer concerning body if I recall that correctly.

Hope it helps

(though, nested body is still a struggle)


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ