Azure / api-management-developer-portal

Developer portal provided by the Azure API Management service.
MIT License
479 stars 307 forks source link

APIM portal Developer Try It page - not sending subscription key in header #2281

Closed ilyasse05 closed 9 months ago

ilyasse05 commented 10 months ago

important ! Wich kind of API GraphQL API

Bug description The Ocp-Apim-Subscription-Key header value is not being set the first time using the 'Try It' feature. A workaround is to select a different subscription key from the dropdown.

Reproduction steps

  1. Go to the API Details page
  2. Select an operation
  3. Click on the 'Try it' button
  4. Notice that there is no Ocp-Apim-Subscription-Key listed in the Headers section.
  5. Fill out any required parameters and click 'Send'
  6. You will receive a 401 - Unauthorized response.
  7. Even if i add manualy Ocp-Apim-Subscription-Key it'is still not working

Expected behavior The default subscription key that is filled in the dropdown should also be set as the default Ocp-Apim-Subscription-Key header.

Is your portal managed or self-hosted? Managed

API Management service name [e.g., contoso-api]

Environment Operating system: Windows Browser: Chrome Additional context

malincrist commented 10 months ago

Hello @ilyasse05 , thanks for reaching out! I was not able to reproduce the issue you described. Can you please share your instance name and the API you re having issues with to apimportalfeedback@microsoft.com so we can investigate this further?

ilyasse05 commented 10 months ago

Hello @malincrist, i found the root cause of the issue

My API GraphQL calls an AzureFunction, in url of azure function we have a param with a default value (personalized param for ower use) and the problem is that in developer portal the APIM add a second parameter that is forwarded to azurefunction with by adding "?subscription-key=XXXX" then the full url contains ? twice

image

the workaround is to add this policy in APIM, but if an user add another param it doesn't work

ilyasse05 commented 10 months ago

important ! i'am using a graphQL API with API REST HTTP it works correctly

malincrist commented 10 months ago

@ilyasse05 , got it now, thanks for the explanation! 😊