openresty / lua-nginx-module

Embed the Power of Lua into NGINX HTTP servers
https://openresty.org/
11.17k stars 2.01k forks source link

File Format Change from csv to string while adding data in request body #1973

Open vikas-nykaa opened 2 years ago

vikas-nykaa commented 2 years ago

I am adding one parameter in request body if POST request (Content-Type= "multipart-form/data") but after adding when i set edited body in kong request, file format changed from csv to string. And i am getting 400 Bad Request because MultiPartFile parameter not found in Request Body. Pls help

Code:

local body = kong.request.get_body() body["vendor"]="{ "vendorId" : "vikas", "vendorName" : "vikas" }" kong.service.request.set_body(body)

Request Body:

Screenshot 2021-11-14 at 4 16 59 PM
zhuizhuhaomeng commented 2 years ago

can you give a minimal nginx.conf that can reproduce this issue

vikas-nykaa commented 2 years ago

@zhuizhuhaomeng You can reproduce this issue by upload csv file in Request body of multipart-form/data request. And in lua scripts add one more parameter in request body. after that API will not work fine

zhuizhuhaomeng commented 2 years ago

you can print the body to see if it is expected. if the body get by kong.request.get_body() is multiform format, then it is not your expected?