2
votes

In my nodejs application I used following line of code to get req.body

app.use(bodyParser.urlencoded({ extended: false }));

this is working fine but one request to my application which throw following error

UnsupportedMediaTypeError: unsupported charset "ISO-8859-1" at urlencodedParser (/var/www/payment/node_modules/body-parser/lib/types/urlencoded.js:108:12) at Layer.handle [as handle_request] (/var/www/payment/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/var/www/payment/node_modules/express/lib/router/index.js:317:13) at /var/www/payment/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/var/www/payment/node_modules/express/lib/router/index.js:335:12) at next (/var/www/payment/node_modules/express/lib/router/index.js:275:10) at jsonParser (/var/www/payment/node_modules/body-parser/lib/types/json.js:118:7) at Layer.handle [as handle_request] (/var/www/payment/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/var/www/payment/node_modules/express/lib/router/index.js:317:13) at /var/www/payment/node_modules/express/lib/router/index.js:284:7

I almost spend much time. but if I remove

app.use(bodyParser.urlencoded({ extended: false }));

this line then working for that request but other I unable to retrieve data from all other request.

Is there any way to fixed this.

1

1 Answers

1
votes

You can modify the original request header, to UTF-8.

I found no easy way to intercept the urlencoded parser, so i just changed the encoding to utf8