1

I would like to use UnityEngine.Networking and StartCoroutine() to retrieve data from Bing API in Unity/C#. I am getting Error 401 which is:

{"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."}}

The url that I am attempting to call is:

https://[**MyEndpoint**]/bing/v7.0/news/trendingtopics?BingAPIs-Market=en-US&Ocp-Apim-Subscription-Key=[**KEY**]

I assume the reason for rejection is that I explicitly added Ocp-Apim-Subscription-Key header in the url but not sure %100.

A.I.
  • 37
  • 7
  • 1
    The subscription key is a header and doesn't belong in the URL. See : https://learn.microsoft.com/en-us/azure/cognitive-services/bing-video-search/concepts/sending-requests – jdweng Oct 28 '20 at 02:11
  • how's going? Has your issue been solved ? – Stanley Gong Oct 29 '20 at 01:29
  • @jdweng thanks for the help! I tried to read documentation before I posted this question, but I got confused due to the lack of knowledge that I have in C# and Azure, but I am sure I will get it one day! now I know header is not really belong in the URL so thanks for that – A.I. Oct 30 '20 at 06:14

2 Answers2

0

As @jdweng indicated, you should specify your subscription key in the request header, just as below : enter image description here

If it is necessary for you using the subscription key in the request URL,the param here should be subscription-key instead of Ocp-Apim-Subscription-Key just as below:

enter image description here

Stanley Gong
  • 11,522
  • 1
  • 8
  • 16
0

Bing API is RESTful API and expects the authentication key in the request header

Rajpatil
  • 11
  • 1