Reputation: 31
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 throws 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
If I remove the previous line, then it works for that request, but in all other requests, I am unable to retrieve data. Is there any way to fix this?
Upvotes: 3
Views: 1927
Reputation: 21
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
Upvotes: 2