cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DavidNoble
New Member

Custom Connector - 401 Unauthorized Response - Access denied due to missing subscription key (Ocp-Apim-Subscription-Key)

Hi,

 

I have a REST API that I can successfully call from Postman using a Ocp-Apim-Subscription-Key in the header for authentication.

 

I have created a Custom Connector to this service, choosing "API Key" as the security type and putting Ocp-Apim-Subscription-Key in both the API Key Parameter Label and Parameter Name.

 

When I try to test this in the Custom Connector test tool (after creating a connection instance and filling in the API key); I get a 401 unauthorized error:

 

"Access denied due to missing subscription key. Make sure to include subscription key when making requests to an API."

 

Further analysis shows that the Key appears to be being sent as a parameter rather than a header value, i.e.:

 

It's being sent as:

{

  "content-length": "152",

  "content-type": "application/json",

  "date": "Thu, 05 Nov 2020 14:41:33 GMT",

  "www-authenticate": "AzureApiManagementKey realm=\"https://qub-api-management.azure-api.net/CompanyName\",name=\"Ocp-Apim-Subscription-Key\",type=\"header\"",

  "x-ms-apihub-cached-response": "false"

}

 

Whereas it should be:

 

{

  "content-length": "152",

  "content-type": "application/json",

  "date": "Thu, 05 Nov 2020 14:41:33 GMT",

  "www-authenticate": "AzureApiManagementKey realm=\"https://qub-api-management.azure-api.net/CompanyName\",
 “Ocp-Apim-Subscription-Key": “subscriptionKey”,

  "x-ms-apihub-cached-response": "false"

}

 

Any ideas on how to resolve this? Is this something to do with the way I've configured this custom connector or is it likely to be a wider problem with my Azure environment?

 

Thanks,
David

1 REPLY 1
ManishJain
Solution Sage
Solution Sage

HI @DavidNoble ,

 

Can you please share your custom connector steps . Also once you have created custom connector you should be able to see swagger editor at the top . Scroll down till the bottom , you should be seeing security definitions over there.

 

Thanks

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Users online (2,531)