I am new to Azure APIM and want to know how to get subscriber ID or anything which can uniquely identifies every subscriber of my API.
-
get it where? in apim? or? – 4c74356b41 Sep 27 '18 at 10:53
-
Yes in APIM. Firstly i want to get the value of that attribute which can uniquely identifies each subscriber then I need to append specific attributes in the request based on that subscriber. – Zain Khan Sep 27 '18 at 11:11
2 Answers
You can use APIM management api to get the subscription ID. In your APIM Instance>Management API There you can find the management url and the token to call the endpoint can be generated.
Specifically to get all subscriptions, you can use below endpoint within management url :
GET: https://{your management url}/subscriptions/?api-version=2018-01-01
Or
specifically for a product
https://{your management url}/products/{productId}/subscriptions?api-version=2018-01-01
Below is the Rest API reference https://learn.microsoft.com/en-us/rest/api/apimanagement/subscription
Or within a APIM policy,
you can find using context
variables.
https://learn.microsoft.com/en-us/azure/api-management/api-management-policy-expressions
context.Subscription.Id

- 679
- 8
- 19
-
the REST API suggested didn't worked for me. Is there any other mean to get the APIM subscription ID? – gsscoder Oct 16 '20 at 05:55
-
That is so strange. I think you doesnt enabled the option of Rest api in the portal. – VinuBibin Oct 21 '20 at 19:14
Fo those who are not clear on the answer provided by @VinuBibin, you can get the subscription id during request, inside the policy and inject it into headers as follows:
<set-header name="subscription" exists-action="override">
<value>@(context.Subscription.Id)</value>
</set-header>

- 6,254
- 8
- 39
- 67