Assistance Needed for Converting JSON Request Body to JSONP in Inbound Policy

Mithila Lishan 116 Reputation points
2025-02-07T03:48:43.6966667+00:00

I am currently searching for a policy that allows converting a JSON request body (Content-Type: application/json) into a JSONP request body (Content-Type: application/jsonp or text/plain) to meet our backend requirements. However, our API need to design to send JSON requests but backed accepts JSONP(text/plain). While following the documentation, I attempted to modify the json-to-xml transformation to json-to-jsonp, but policy validation indicates that such an option is not available.

I found documentation on a JSONP converter, but it is related to the outbound section. However, I need to apply this policy in the inbound section.

I would appreciate your support in resolving this issue.

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,329 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Loknathsatyasaivarma Mahali 795 Reputation points Microsoft External Staff
    2025-02-07T09:57:49.3833333+00:00

    Hello @Mithila Lishan,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    The Azure API Management does not provide a direct policy to convert a JSON request body to JSONP in the inbound section. The jsonp policy is specifically designed to add JSONP support to an operation or an API, but it is intended for outbound responses rather than for transforming inbound requests.

    To achieve your goal, you may need to handle the conversion at the application level or use a custom policy that processes the incoming JSON request and formats it as JSONP before sending it to the backend. Unfortunately, the existing policies like json-to-xml or json-to-json do not support this specific transformation.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.