You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 10本地XAMPP环境下如何正确提交HERE API POST定位请求?

Fixing HERE Positioning API Errors in Local XAMPP Development

Alright, let's tackle these two issues you're facing with the HERE Positioning API in your Windows 10 + XAMPP local setup (http://localhost:8003/myFolder/):

1. First Error: POST https://pos.ls.hereapi.com/positioning/v1/locate... net::ERR_ABORTED 400 (Bad Request)

A 400 Bad Request means the API is rejecting your request due to invalid formatting, missing data, or incorrect parameters. Here's what to check:

  • Validate your API Key: Double-check that your apiKey is active, has permissions for the Positioning API, and isn't truncated (your snippet shows Lxj-xbibfpSHLMw1U...blabla—make sure the full, unmodified key is included).
  • Check Request Body Format: The /positioning/v1/locate endpoint requires a specific JSON body with positioning data (like WiFi access points, cell towers, or GPS coordinates). A valid WiFi-based request example:
    {
      "wifiAccessPoints": [
        {
          "macAddress": "AA:BB:CC:DD:EE:FF",
          "signalStrength": -65,
          "age": 0
        }
      ]
    }
    
  • Verify Request Headers: Ensure you're sending the correct Content-Type header—HERE specifies application/vnd.here.layerObjectList+json; charset=utf-8 for this endpoint. Missing or mismatched headers will trigger a 400 error.
  • Check URL Parameters: Confirm there are no typos in the API endpoint URL, and the apiKey is properly appended as a query parameter.

2. Second Error: POST http://host/path?CORSH=%7B%22Content-Type%22... net::ERR_NAME_NOT_RESOLVED

This error has two clear fixes—let's break them down:

  • Replace the Invalid Placeholder URL: http://host/path is a dummy address; swap it with the real HERE API endpoint: https://pos.ls.hereapi.com/positioning/v1/locate
  • Stop Putting CORS Headers in the URL: CORS headers belong in the request headers, not as query parameters. This is causing malformed requests and unnecessary complexity. If you're using JavaScript fetch, your code should look like this:
    fetch('https://pos.ls.hereapi.com/positioning/v1/locate?apiKey=YOUR_FULL_API_KEY', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/vnd.here.layerObjectList+json; charset=utf-8',
        'Accept': 'application/json; charset=UTF-8',
        'GroupId': 'FGx1AWaAzKOo0imNkLmf',
        'AuthServiceId': 'here_app',
        'Auth-Identifier': 'Ykv6MmZ03OJtiFD4R7Ht',
        'Auth-Secret': 'AXqUNisVW46XJs9_pxuzOzneKlYPrY5X_blablabla'
      },
      body: JSON.stringify(yourPositioningDataObject)
    })
    
  • Local Dev CORS Workaround: If you still hit CORS errors (common when localhost calls external APIs), set up a reverse proxy in XAMPP's Apache config to avoid cross-domain issues. Add this to your httpd.conf or a virtual host file:
    ProxyPass /here-proxy https://pos.ls.hereapi.com
    ProxyPassReverse /here-proxy https://pos.ls.hereapi.com
    
    Then update your request URL to use the proxy: http://localhost:8003/here-proxy/positioning/v1/locate?apiKey=YOUR_API_KEY—this makes the request appear same-origin to your local dev server.

内容的提问来源于stack exchange,提问作者Serbona Applications

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 21:22:56