如何在新版Google Places API请求中添加languageCode参数?
新版Google Places API languageCode 参数传递解决方案
新版Google Places API(v3)的languageCode参数必须放在POST请求的JSON请求体中,这是和旧版API的关键差异,之前的URL拼接、请求头传参方式都不再适用。
正确请求示例(以Place Details接口为例)
- 使用
POST请求方法 - 设置请求头:
Content-Type: application/json - 请求体包含
languageCode字段,示例代码:
{ "placeId": "你的地点ID", "languageCode": "zh-CN", "fields": ["name", "formatted_address", "geometry"] }
常见错误排查
- 确认调用的是新版v3端点:
https://places.googleapis.com/v3/places/{placeId}/details - 检查JSON请求体格式是否正确,无语法错误
languageCode需符合ISO 639-1标准(如en、ja、zh-TW等)- 旧版的
languageURL参数在v3中已废弃,请勿混用
内容的提问来源于stack exchange,提问作者Freshron
相关产品推荐
相关产品推荐

