How to fix "Access denied due to invalid subscription key or wrong API endpoint error"

Sandeep Nair 10 Reputation points
2024-01-24T10:11:02.46+00:00

Hello All, I am new to the world of AZURE and I am trying to use the Document Intelligence service for OCR scanning. As part of the product I am building, we just obtained a subscription through the Microsoft Founders Hub program. The name of the subscription is Microsoft Azure Sponsorship. I went ahead and created a resources group and then activated my Document Intelligence service. From here I got two keys and an endpoint. My back end code is in Node JS and on passing a document to the endpoint the request seems to be failing. There is an URL called the Operation Location and in that URL I can clearly see this error message "

{"error":{"code":"401","message":"Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource."}}

I am following the API documentation for the Document Intelligence and following step by step. Can someone guide me on what I am doing wrong.

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,710 questions
{count} votes

1 answer

Sort by: Most helpful
  1. YutongTie-MSFT 52,776 Reputation points
    2024-01-25T01:22:39.1766667+00:00

    @Sandeep Nair
    Thanks for reaching out to us, may I know if you just created your subscription within 24 hrs?

    It may be some delay for the subscription and the resource. As you are working on JS, you may need to include your endpoint and subscription Id in your header, could you please share the document or the code same you are working now?

    Here are a few things you can try to resolve the issue generally -

    Double-check that you are using the correct subscription key and API endpoint. Make sure that the subscription key is valid and that it is associated with an active subscription. Also, ensure that you are using the correct regional API endpoint for your resource.

    Check that your subscription has the necessary permissions to access the Document Intelligence service. You may need to adjust the permissions on your subscription or resource group to ensure that you have the necessary access.

    Verify that your code is correctly passing the subscription key and API endpoint to the Document Intelligence service. Double-check that the values are being passed correctly and that there are no typos or other errors in your code.

    If you are still experiencing issues, try contacting Microsoft support for further assistance. They may be able to help you troubleshoot the issue and resolve it more quickly.

    I hope this helps! Let me know if you have any further questions or concerns.

    Regards,

    Yutong

    -Please kindly accept the answer if you feel helpful to support the community, thanks a lot.


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.