OCAPI JSONP 19.8

JSONP (JSON with padding) allows a browser page to request data from a server in a different domain. Normally, a Web API request returns a plain JSON document, which requires the client to parse the JSON document. There are some Browser JavaScript cases where it is much more efficient to respond with JavaScript code instead of with a JSON document. The response is directly evaluated by the JavaScript interpreter and is not parsed by a JSONParser. The response, in these cases, is merely a JSON document with a JavaScript function call wrapped around it.

The Open Commerce API offers the URL request parameter callback. The value of this parameter is the name of the JavaScript function that is wrapped around the JSON document.


REQUEST:
GET /dw/shop/v19_8/products/99225?client_id=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&pretty_print=true&callback=parseResponse HTTP/1.1
Host: example.com

RESPONSE:
HTTP/1.1 200 OK
Content-Length: 351
Content-Type: text/javascript;charset=UTF-8
X-Content-Type-Options: nosniff

/**/parseResponse({
  "_v" : "19.8",
  "brand" : "Apparelstore",
  "id" : "99225",
  "name" : "Boot Sauce™ Brown Cream"
})