Cross-Domain JavaScript Requests

Browsers enforce the same-origin policy. A web application hosted on a different origin can call the HERE Off-Street Parking API only if the API's Cross-Origin Resource Sharing (CORS) configuration allows that origin. JavaScript cannot enable CORS; the server must return the appropriate CORS headers.

Requests that include an Authorization header trigger a browser preflight request. The API must allow the application's origin, the GET method, and the Authorization header. Confirm that the API endpoint and your application's origin are allowed. If the browser blocks the request, use a trusted server-side component to call the API instead. Do not expose OAuth client secrets in browser code.

In order to support browser platforms which do not yet implement Cross-Origin Resource Sharing, GET requests can alternatively be made using JSONP. To use JSONP, your application simply supplies the name of its callback function in the jsoncallback or jsonpCallback query string parameter.

For example, to use JSONP to search Parking facilities with a callback named myCallbackFunction, you could make a request like the example below:

curl --get \
  --header "Authorization: Bearer {YOUR_TOKEN}" \
  --data-urlencode "prox=52.516667,13.383333,5000" \
  --data-urlencode "jsoncallback=myCallbackFunction" \
  "https://parking-v2.cc.api.here.com/parking/facilities.json"
📘

Note

The JSONP mechanism only works for GET requests.


Did this page help you?