我是 dotNetRDF 和 SPARQL 的新手,我正在尝试从 DBPedia 检索一些人员数据。我已经编写了这个查询并在http://dbpedia.org/sparql的在线编辑器上成功测试了它:
问题是当我尝试使用下面的代码启动查询时,我得到一个 HTTP 异常 400,无效请求:
SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri("http://dbpedia.org/sparql"));
//Make a SELECT query against the Endpoint
SparqlResultSet results = endpoint.QueryWithResultSet(@"
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n
PREFIX type: <http://dbpedia.org/class/yago/>\n
PREFIX prop: <http://dbpedia.org/ontology/>\n
\n
select DISTINCT ?person ?name ?birth ?shortDescription where {\n
?person a dbpedia-owl:Person ;\n
foaf:name ?name ;\n
dbpedia-owl:birthDate ?birth ;\n
dbpprop:shortDescription ?shortDescription .\n
filter langMatches(lang(?name),'en') .\n
filter langMatches(lang(?shortDescription),'en') \n
}\n
LIMIT 10");
foreach (SparqlResult result in results)
{
Console.WriteLine(result.ToString());
}
任何帮助,将不胜感激。提前致谢 ;)