【发布时间】:2017-02-28 17:19:33
【问题描述】:
我正在使用 Node js 中的 Request 调用 Google Place api Web 服务。请求正文给出了错误Invalid request. One of the input parameters contains a non-UTF-8 string.,因为我在 url 参数(keyword 参数)中使用了高棉字符。
nearByUrl = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=11.55082623,104.93225202&radius=400&keyword=ស្ថានីយប្រេង&key=' + MY_KEY;
request({
url: nearByUrl,
json: true
}, function (error, response, body) {
console.log(JSON.stringify(body, null, 2));
})
但是,当从 Chrome 浏览器调用具有高棉字符的完全相同的 URL 时,我可以获得带有结果的有效 JSON。
这个问题和Request有关吗?
我该如何解决这个问题?
【问题讨论】:
-
你能给我们看一些代码吗?
-
@IvanVasiljevic 刚刚用代码编辑了问题
标签: node.js utf-8 request google-places-api