Return mock data in developer portal Try it and return real data through client

NC0202 201 Reputation points
2020-11-05T07:20:14.167+00:00

Hi,

May we need your advice on the following scenario ?

We want to apply APIM to company internal teams and allow them to try API via developer portal to know what the data scheme looks like . At this moment, no real data returned.

If they want to use this API to get real data, they have to get approval by other means. After approved, APIM admin will approve their submission to give subscription key.

Is there a way for one API to return mock data and no need subscription key when user hits "try it" through developer portal, but return real data (need subscription key) if calling from the client(ex: Postman) ?

What I can think of is creating two identical APIs and tweak trial one a bit.
apiA : hit backend, with subscription key enabled
apiA_Trial : return mock data, no subscription key is required

Not a elegant way, so just want to know if you have better design on this ?

Thank you

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

Accepted answer
  1. ChaitanyaNaykodi-MSFT 27,476 Reputation points Microsoft Employee Moderator
    2020-11-06T21:36:04.513+00:00

    Hello @NC0202 , Thank you for reaching out. I could think of following designs which could satisfy your requirements.
    1.] You can use control flow policy to identify if the request consists subscription-key if not then you can define a Mock response policy in your inbound policy itself to send mock data. You can implement something similar as discussed here.
    2] Using the control flow policy above you also point the request to a different backend service which can respond with the required mock data.

    Please let me know if the above solution does not satisfy your requirement, I will glad to continue with our discussion. Thank you!

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.