Dave
Dave

Reputation: 57

LUIS Add Utterance in code JSON POST failing

Following this example:

https://learn.microsoft.com/en-us/azure/cognitive-services/luis/luis-quickstart-cs-add-utterance

I am trying to send an utterance to my LUIS App. It keeps on failing with this response message:

{
  "error": {
    "code": "BadArgument",
    "message": "Failed to parse example labeling objects. Parameter name: exampleLabelObjects"
  }
}

My input body is:

{
  "text": "hi, what can I help you with?",
  "intentName": "Help",
  "entityLabels": []
}

And according too the link if you send an utterance without any entity labels the above is correct.

The entityLabels field is required. If you don't want to label any entities, provide an empty list as shown in the following example:

[
    {
        "text": "go to Seattle",
        "intentName": "BookFlight",
        "entityLabels": [
            {
                "entityName": "Location::LocationTo",
                "startCharIndex": 6,
                "endCharIndex": 12
            }
        ]
    },
    {
        "text": "book a flight",
        "intentName": "BookFlight",
        "entityLabels": []
    }
]

The C# to build the object is as follows:

public class LUISUtterItem
    {
        public string utterances;
        public string text;
        public string intentName;
        public List<exampleLabelObjects> entityLabels;

    }

    public class exampleLabelObjects
    {
        public string entityName;
        public int startCharIndex;
        public int endCharIndex;
    }

I call it using:

LUISUtterItem itm = new LUISUtterItem(); 

            //itm.utterances = materialArray[1];
            itm.text = materialArray[1];
            itm.intentName = materialArray[2];
            itm.entityLabels = new List<exampleLabelObjects>();

I have also tried not including an "entityLabels" object, as well as a string list that just gets initiated with the same result.

Any help will be appreciated.

Upvotes: 0

Views: 1094

Answers (2)

tumblewood
tumblewood

Reputation: 73

I faced the same issue. Solved by sending the body as: { "text": "hi", "intentName": "Greetings" }

Don't put entityLabel if it is not needed.

Upvotes: 0

Dave
Dave

Reputation: 57

So it seems like all you have to include in the body is "[]" around it and it worked:

[{
  "text": "hi, what can I help you with?",
  "intentName": "Help",
  "entityLabels": []
}] 

Upvotes: 2

Related Questions