如何发送自定义附加地址信息的 POST 请求

How to send a POST request for the Custom Location Extension

我正在试用 HERE Maps REST API - Custom Location Extension and run into a problem. It was mentioned that a POST request using the Corridor Search Using Coordinates for Custom Locationscan be used instead of a GET request if I want to submit a request with a large coordinate set, but the example POST request was not in the documentation.

我试图弄清楚如何提交 POST 请求,这就是我的进展:

要求:

POST /v1/search/corridor HTTP/1.1
Host: customlocation.cit.api.here.com

?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&route=52.51978,13.388211,
52.5198326,13.3882084,
52.5198402,13.3883495,
52.5147705,13.3891602,
52.514758,13.389155
&radius=100
&layerId=30

响应:

{
  "message": "Required parameters have not been provided",
  "status": "400 Bad Request",
  "error": "Required String parameter 'route' is not present",
  "targetLayerId": null
}

备注:

编辑: (进一步审理)

我还尝试将所有查询参数从主体移动到 url 除了 route

POST /v1/search/corridor ?app_id=Qk8YkRrHMbbbpkVipwIZ
&app_code=tYSXrAAHGEOcUB_cxbPQSA&radius=100&layerId=852 HTTP/1.1

route=52.51978,13.388211, 52.5198326,13.3882084, 
52.5198402,13.3883495, 
52.5147705,13.3891602, 
52.514758,13.389155

回应: { "message": "Required parameters have not been provided", "status": "400 错误请求", "error": "Required String parameter 'route' is not present", "targetLayerId": 空 }

我稍微研究了一下,通过从查询字符串中删除 route 并将其作为 key/value 对形式发送,能够通过 POSTing 获得响应。我使用了演示凭证,并且正在使用 Chrome 插件 "Postman" 进行测试。我的 POST URL 看起来像这样:

https://customlocation.cit.api.here.com/v1/search/corridor?layerId=30&radius=100&app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg

然后我设置 "route" 的 form-datax-www-form-urlencoded 键,然后值是一串坐标。然后它返回一个成功的响应。我在尝试将任何有效负载作为原始文本时确实遇到了您提到的相同错误。

我不知道的事情:表单数据值是否有一些限制?

祝你好运。我确实同意官方文档对 POST 示例的描述非常简单,尤其是因为它们明确建议将其作为发送大负载的方法。