NullReferenceException on a new client creation.
Closed this issue ยท 7 comments
Hello @iliuhin, this error occour when connection with your subscription fails. Please, check if your location is really WestEurope. For testing, try changing it to WestUS. For example:
var client = new LuisProgClient(SUBSCRIPTION_KEY, Location.WestUS);
var app = client.GetAppByNameAsync("SDKTest").Result;
Hi @andreluizsecco,
I did change the location to WestUS and the problem still remained. (But I'm pretty sure my app is registered in WestEurope).
But i noticed something else, i think there is a problem with the _baseUrl variable:
In your case the url is:
https://westeurope.api.cognitive.microsoft.com/luis/api/v2.0
But if to look at Microsoft Documentation the url is the following:
https://westeurope.api.cognitive.microsoft.com/luis/api/v2.0/apps
The _baseUrl of the SDK is correct. It will receive the "/apps" only when accessing the features related to apps, which can be seen, for example, in this line of source code: https://github.com/andreluizsecco/Cognitive-LUIS-Programmatic/blob/3e4231665a42661ea9f45af2ad0a0dc374fe9f6c/Cognitive.LUIS.Programmatic/LuisProgClient.cs#L22
I'll need more information to find out the cause.
Could you get a print of the entire screen on the "publish" tab of your app? Delete the keys from the image.
Ex:
If you prefer, send me an email (contato@andresecco.com.br) with your subscription key for my testing.
@andreluizsecco Thanks a lot for help, for some reason it worked without a problem when i used my Starter_Key.
I find it pretty strange that the other keys that I've generated don't work...
Btw, is there a way to retrieve/delete/edit the labeled utterances using Cognitive-LUIS-Programmatic?
I can not reproduce your problem here.
If you can contact me at contato@andresecco.com.br to test with your subscription key.
These features (retrieve/delete/edit the labeled utterances) are planned for version 1.1 (See the roadmap here : https://github.com/andreluizsecco/Cognitive-LUIS-Programmatic/wiki/roadmap)
To close the issue:
LUIS can use two type of keys: Authoring Key and Endpoint Key.
- So basically the Authoring Key (called also Starter_Key) can be used with authoring Microsoft APIs, such as LUIS Programmatic APIs v2.0.
- But when the Endpoint Key (the one generated using Azure), is used with authoring APIs, then the error: "401 error - access denied due to invalid subscription key" is thrown (or in this case, a null object). The Endpoint key is used only when you deal with production endpoint queries.
Link: https://docs.microsoft.com/en-us/azure/cognitive-services/luis/luis-concept-keys
@andreluizsecco Once again, thank you for help. Waiting for upcoming releases.
Same problem here, the solution was very useful, thanks!