Wikidata API always returns Null Pointer exception

I use wikidata api to retrieve an entity using my English title,

wdf = WikibaseDataFetcher.getWikidataDataFetcher();
eid = wdf.getEntityDocumentsByTitle("enwiki", entitle);

Previously, with an older version of wikidata-api, I was able to run it smoothly. After upgrading to version 5.0.0, I always get the following error:

Exception in thread "main" java.lang.NullPointerException
    at org.wikidata.wdtk.wikibaseapi.ApiConnection.fillCookies(ApiConnection.java:544)
    at org.wikidata.wdtk.wikibaseapi.ApiConnection.sendRequest(ApiConnection.java:346)
    at org.wikidata.wdtk.wikibaseapi.WbGetEntitiesAction.wbGetEntities(WbGetEntitiesAction.java:187)

How to fix it?

+4
source share
1 answer

I get the same problem. I tried using the latest version of github and getting the same exception. I am performing a sample from the documentation, i.e. A simple call:

Map<String, EntityDocument> results = wbdf.getEntityDocuments("Q80", "P31");

The code does not seem to check for a specific cookie. I added verification, recompiled and everything works.

Go to ApiConnection.javahaps43

if (headerCookies != null)
    for (String cookie : headerCookies) {

There is no guarantee!: -)

+4
source

Source: https://habr.com/ru/post/1613411/


All Articles