Cannot use the Knowledge academic API

北战南征 提交于 2020-01-14 18:59:30

问题


I have a problem when I try to use the function similarity proposed in the academic knowledge API.

I tested the following commad to compute the similarity between two string:

curl -v -X GET "https://api.labs.cognitive.microsoft.com/academic/v1.0/similarity?s1={string}&s2={string}" -H "Ocp-Apim-Subscription-Key: {subscription key}"

The error that I get is :

{"error":{"code":"Unspecified","message":"Access denied due to invalid subscript ion key. Make sure you are subscribed to an API you are trying to call and provi de the right key."}}

  • Curl_http_done: called premature == 0
  • Connection #0 to host (nil) left intact

Can you tell how can I generate the Ocp-Apim-Subscription-Key?

At the moment I used the key generated automatically when I visit the following url : https://labs.cognitive.microsoft.com/en-us/subscriptions?productId=/products/5636d970e597ed0690ac1b3f&source=labs

Thank you for your help


回答1:


Unfortunately, primarily not an answer to your question, but rather a warning for all with the "same" problem, who could came across the original question like me, as the question helped me to solve a very, very similar problem: check whether you are using api.labs.cognitive.microsoft.com instead of westus.api.cognitive.microsoft.com. But may be you need the opposite.

It seems the whole project has been moved inside Microsoft (see https://www.microsoft.com/en-us/research/project/academic/articles/sign-academic-knowledge-api/, I would bet that this blogpost was at the top of some "entrypoint" blog even yesterday morning, but now I am not able to find this blog, perhaps the things are changing right now) and may be the project is somewhere in the middle of the transition process and not all documentation etc. corresponds with the new state. E.g. https://docs.microsoft.com/en-us/azure/cognitive-services/academic-knowledge/home, in the submenu Reference, links to two "versions" of API which seem to be almost same except for the URLs westus.api... and api.labs..., respectively. But there seem to be no info what is the difference, which one should be preferred etc.

My original keys expired yesterday, thus I generated new ones and was not able to use them until I have changed the URL to api.labs..., thanks to your question. May be you have the opposite problem, that you still have the "old" keys, so you need to use the "old" url westus.api..., but I am not able to test it, as my original keys which worked with westus.api... are expired.

Both your query and your link where to get keys are OK and work for me. Just one additional detail: did you try the circle arrow next to the key value, which generates a new key? May be your key is somehow broken or expired and this could solve your problem. You can also try to create a completely new account at MS site.

PS: I have added microsoft-cognitive tag as MS refers to https://stackoverflow.com/questions/tagged/microsoft-cognitive from many pages related to Cognitive Services




回答2:


I think you need to sign up for a free account, there is a link you can follow from here: https://westus.dev.cognitive.microsoft.com/docs/services/56332331778daf02acc0a50b/operations/58076bdadcf4c40708f83791

Except for the invalid key, you curl-call looks right.




回答3:


You need a valid subscription key to be able to make API calls.

Production key

Have a look at this page on how to created the needed services in the Azure portal and how to find the endpoint, as well as they key from there.

Trial key

However, if you just want to try out the service, you can create a temporary key here. This key is very limited in use but it should get you up and running.

Limitations are:

  • 50,000 transactions per month, up to 20 per second.
  • Trial keys expire after a 90 day period.


来源:https://stackoverflow.com/questions/49276196/cannot-use-the-knowledge-academic-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!