GuidesAPI Reference
Guides

How to create cross-domain JavaScript requests

Browsers often prevent access to certain servers due to security restrictions. Cross-domain JavaScript Requests allow developers to work around security restrictions that would otherwise prevent an application from directly contacting the EV Charge Points API. In order to allow full server access, the HERE EV Charge Points API v2 provides a means of enabling client-side cross-origin requests that allow JavaScript resources to be fetched from another domain.

For more information, see Cross-Origin Resource Sharing. HERE EV Charge Points API v2 currently uses all headers and parameters of this method.

In order to support browser platforms which do not yet implement Cross-Origin Resource Sharing, GET requests can be made with JavaScript Object Notation with Padding (JSONP). To use JSONP, your application must include the name of its callback function in the jsoncallback or jsonpCallback query string parameter.

For example, to use JSONP to search EV stations with a callback named myCallbackFunction, you could make a request using a bearer token:

GET https://ev-v2.cc.api.here.com/ev/stations.json
?prox=52.516667,13.383333,5000
&jsoncallback=myCallbackFunction
-H "Authorization: Bearer {YOUR_TOKEN}'
    

Below is the same request when using an API Key:

GET
https://ev-v2.cc.api.here.com/ev/stations.json
?prox=52.516667,13.383333,5000
&jsoncallback=myCallbackFunction&apiKey={YOUR_API_KEY};
📘

Note

JSONP can only be used with GET requests. POST requests must use the Cross-Origin Resource Sharing method discussed above.