-2

https://api.bing.microsoft.com/v7.0/images/search?Ocp-Apim-Subscription-Key=9e572eb4609e4042b490fc42b2cb004c&q=apples

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

Ladadadada
  • 26,337
  • 7
  • 59
  • 90

1 Answers1

1

That key works fine if you follow the documentation.

curl -H "Ocp-Apim-Subscription-Key: 9e572eb4609e4042b490fc42b2cb004c" https://api.bing.microsoft.com/v7.0/search?q=apples

HTTP/1.1 200 OK
...

The documentation says that the key should be passed as a header, not as a query parameter. If you're just clicking on that link in a browser it's not going to work that way. You need to write code that adds the header. A lot of developers use Postman for testing purposes.

Side note: The key should also probably be considered a secret because anyone who knows it can use up all your quota and if you're a paying customer you'll end up having to pay for what they use. Now that this one has been published you should delete it, create a new one and keep that one secret.

Ladadadada
  • 26,337
  • 7
  • 59
  • 90