Adriano12356
Adriano12356

Reputation: 23

Indico API Wrapper For Java Returning Key Not Found

I'm attempting to use indico's sentiment analysis api, I've debugged and inspected the "indico" object, and confirmed the correct api key is stored within it. I am also able to make calls to the API using curl from terminal, so I don't believe its my network settings (unless its something java specific?).

The code:

    public double querySentiment(String qsent) throws UnsupportedOperationException, IOException, IndicoException{
    double response = 0;

    indico = new Indico(apikey);

    IndicoResult single = indico.sentiment.predict(qsent);
    log.inf("QUERY SEND SUCCESSFUL");

    response = single.getSentiment();
    log.inf("QUERY RECEIVE SUCCESSFUL");
    return response;
}

The exception:

java.lang.IllegalArgumentException: API key not found. To use our API, sign up for a free account and api key at http://indico.io/register.

Upvotes: 1

Views: 133

Answers (1)

Nirav Majevadiya
Nirav Majevadiya

Reputation: 104

Wrong code snippet is given on indico API site. You have to pass key in params as well while making an indico object. Below code will work.

HashMap<String,String> params = new HashMap<String,String>();

params.add("api_key",apikey);

indico = new Indico(apikey,params);

Upvotes: 0

Related Questions