2016-04-10 8 views
4

ウィキデータ照会するため、私は、次のコードを使用しますが、私はエンドポイントが返されるエラーメッセージ」を持って、イエナ(3.0.1)を使用してこのサイトを照会したいと思いますContent-Type:現在SELECTクエリでサポートされていないtext/html "それを解決する方法はありますか?同じコードがdbpediaでうまく動作します。おかげ使用イエナ現在、ウィキデータは「<a href="https://query.wikidata.org/" rel="nofollow">https://query.wikidata.org/</a>を」SPARQLエンドポイントを持っている

queryString = "PREFIX bd: <http://www.bigdata.com/rdf#>\n" + 
       "PREFIX wikibase: <http://wikiba.se/ontology#>\n" + 
       "PREFIX wdt: <http://www.wikidata.org/prop/direct/>\n" + 
       "PREFIX wd: <http://www.wikidata.org/entity/>\n" + 
       "SELECT DISTINCT ?country ?countryLabel\n" + 
       "WHERE\n" + 
       "{\n" + 
       "\t?country wdt:P31 wd:Q3624078 .\n" + 
       " ?country wdt:P1622 wd:Q13196750.\n" + 
       " ?country wdt:P30 wd:Q15\n" + 
       "\tFILTER NOT EXISTS {?country wdt:P31 wd:Q3024240}\n" + 
       "\tSERVICE wikibase:label { bd:serviceParam wikibase:language \"en\" }\n" + 
       "}\n" + 
       "ORDER BY ?countryLabel"; 
     query = QueryFactory.create(queryString); 
     qexec = QueryExecutionFactory.sparqlService("https://query.wikidata.org/", queryString); 
     try { 
      ResultSet results = qexec.execSelect(); 
      ResultSetFormatter.out(System.out, results, query); 
     } catch (Exception ex) { 
      System.out.println(ex.getMessage()); 
     } finally { 
      qexec.close(); 
     } 

答えて

7

the documentationによると、エンドポイントは最後に/ SPARQLを持っています。それは

SPARQLクエリは(POSTおよび他の方法の要求は「禁断の403」と拒否されます)https://query.wikidata.org/sparql?query={SPARQL}にGETリクエストでSPARQLエンドポイントに直接提出することができると言います。結果は、デフォルトでXMLとして、またはクエリパラメータformat = jsonまたはAccept:application/sparql-results + jsonヘッダーが指定されている場合はJSONとして返されます。

+2

ご協力ありがとうございます。URLを「https://query.wikidata.org/sparql」に変更すると問題が解決しました。 –

関連する問題