1

我正在向http://api.artsholland.com/sparql?apiKey=27b6abd4129fc9ced3aa5390fd4fb15b发送 HTTP POST 请求

使用此查询:

  string query =
"PREFIX ah: <http://purl.org/artsholland/1.0/>  "
"PREFIX data: <http://data.artsholland.com/>  "
"PREFIX nub: <http://resources.uitburo.nl/>  "
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns/>  "
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema/>  "
"PREFIX owl: <http://www.w3.org/2002/07/owl/>  "
"PREFIX dc: <http://purl.org/dc/terms/>  "
"PREFIX foaf: <http://xmlns.com/foaf/0.1/>  "
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema/>  "
"PREFIX time: <http://www.w3.org/2006/time/>  "
"PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos/>  "
"PREFIX vcard: <http://www.w3.org/2006/vcard/ns/>  "
"PREFIX osgeo: <http://rdf.opensahara.com/type/geo/>  "
"PREFIX bd: <http://www.bigdata.com/rdf/search/>  "
"PREFIX search: <http://rdf.opensahara.com/search/>  "
"PREFIX fn: <http://www.w3.org/2005/xpath-functions/>  "
"PREFIX gr: <http://purl.org/goodrelations/v1/>  "    
"SELECT ?v ?p ?date ?title ?desc ?modified ?type ?genre  "
"WHERE {  "
    "?v a ah:Venue .  "
    "?p dc:modified ?modified .  "
    "?e ah:venue ?v .  "
    "?e ah:production ?p .  "
    "OPTIONAL {{  "
        "?p dc:title ?title .  "
    "}}  "
    "OPTIONAL {{  "
        "?p ah:shortDescription ?desc .  "
    "}}  "
    "OPTIONAL {{  "
        "?p ah:productionType ?type .  "
    "}}  "
    "OPTIONAL {{  "
        "?p ah:genre ?genre .  "
    "}}  "
    "?v geo:geometry ?geometry .  "
    "FILTER (search:distance(?geometry, \"POINT(4.890        52.3764)\"^^<http://rdf.opensahara.com/type/geo/wkt>) < 2000 *  "  "0.00000898315284) .  "
    "?e time:hasBeginning ?date .  "
    "FILTER (?date >= \"2012-09-06T00:00:00Z\"^^xsd:dateTime) .  "
    "FILTER (?date <= \"2012-09-06T23:59:59Z\"^^xsd:dateTime) .  "
    "} ORDER BY ?v  "
    "LIMIT 100  ";

使用这些表单字段:

ofxHttpForm form;
form.action = action_url;
form.method = OFX_HTTP_POST;
form.addFormField("query", query);
form.addFormField("output", "json");
httpUtils.addForm(form);

我得到了 200 OK 的回复,但没有尸体。我已经多次调整查询,但仍然没有有效的返回:(

使用的库是https://github.com/arturoc/ofxHttpUtils

4

1 回答 1

0

我使用演示密钥和您的密钥在同一个端点(使用端点的 Web 界面)上尝试了您的 SPARQL 查询,但得到了 HTTP 500 内部服务器错误(而不是空的 HTTP 200 响应)。

当我使用正确的命名空间并将块中的“{{”替换为“{”时,我确实得到了结果OPTIONAL。Web 界面预定义的命名空间是

PREFIX ah: <http://purl.org/artsholland/1.0/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX time: <http://www.w3.org/2006/time#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX vcard: <http://www.w3.org/2006/vcard/ns#>
PREFIX osgeo: <http://rdf.opensahara.com/type/geo/>
PREFIX bd: <http://www.bigdata.com/rdf/search#>
PREFIX search: <http://rdf.opensahara.com/search#>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
PREFIX gr: <http://purl.org/goodrelations/v1#>
PREFIX gn: <http://www.geonames.org/ontology#>

你必须使用这些(注意其中#/一些,这很重要)。

于 2013-03-29T10:09:25.223 回答