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.

GET /dw/shop/v23_1/products/99225?client_id=[your_own_client_id]&pretty_print=true&callback=parseResponse HTTP/1.1
Host: example.com

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

  "_v" : "23.1",
  "brand" : "Apparelstore",
  "id" : "99225",
  "name" : "Boot Sauce™ Brown Cream"
X OCAPI versions 15.x and 16.x will be retired on March 31, 2021. For dates and more information, see the OCAPI versioning and deprecation policy and this Knowledge Article.
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.