Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 2.2 KB

jsonp-policy.md

File metadata and controls

57 lines (37 loc) · 2.2 KB
title description services author ms.service ms.topic ms.date ms.author
Azure API Management policy reference - jsonp | Microsoft Docs
Reference for the jsonp policy available for use in Azure API Management. Provides policy usage, settings, and examples.
api-management
dlepow
azure-api-management
reference
07/23/2024
danlep

JSONP

[!INCLUDE api-management-availability-all-tiers]

The jsonp policy adds JSON with padding (JSONP) support to an operation or an API to allow cross-domain calls from JavaScript browser-based clients. JSONP is a method used in JavaScript programs to request data from a server in a different domain. JSONP bypasses the limitation enforced by most web browsers where access to web pages must be in the same domain.

[!INCLUDE api-management-policy-generic-alert]

Policy statement

<jsonp callback-parameter-name="callback function name" />

Attributes

Name Description Required Default
callback-parameter-name The cross-domain JavaScript function call prefixed with the fully qualified domain name where the function resides. Policy expressions are allowed. Yes N/A

Usage

Usage notes

  • This policy can only be used once in a policy section.

Example

<jsonp callback-parameter-name="cb" />

If you call the method without the callback parameter ?cb=XXX, it will return plain JSON (without a function call wrapper).

If you add the callback parameter ?cb=XXX, it will return a JSONP result, wrapping the original JSON results around the callback function like XYZ('<json result goes here>');

Related policies

[!INCLUDE api-management-policy-ref-next-steps]