andreluizsecco/Cognitive-LUIS-Programmatic

NullReferenceException on a new client creation.

Closed this issue ยท 7 comments

Hi,

I have a problem when trying to access the appID of my LUIS app.
I double checked the subscription key and the location is set to WestEurope.

What can be the problem for the error below? Do i have to do any additional configuration before creating an LuisProgClient() object?

capture

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:
url

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

thenewlink

https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c2f

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:

image

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...

luisapp

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.

  1. So basically the Authoring Key (called also Starter_Key) can be used with authoring Microsoft APIs, such as LUIS Programmatic APIs v2.0.
  2. 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!