Closed pheyvaer closed 9 years ago
Please share the whole request, e.g. as a CURL. And also the full response.
I just executed the example from the documentation.
Curl
curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "
{
\"query\":\"PREFIX dbpedia:
PREFIX dbpedia-owl:
PREFIX rdf:
PREFIX geo:
CONSTRUCT
{
?museum <@@@entity_uri@@@> .
}
WHERE
{
<@@@entity_uri@@@> geo:geometry ?citygeo .
?museum rdf:type .
?museum geo:geometry ?museumgeo .
FILTER ((?museumgeo, ?citygeo, 10))
}
LIMIT 10\",
\"endpoint\":\"http://dbpedia.org/sparql/\",
\"label\":\"template title\",
\"description\":\"template description\",
\"endpointType\":\"sparql\",
\"visibility\":\"public\"
}" "http://api-dev.freme-project.eu/current/e-link/templates/?informat=application%2Fjson&outformat=application%2Fjson"
Response body
{
"exception": "eu.freme.broker.exception.BadRequestException",
"path": "/e-link/templates/",
"message": "Unterminated string at 61 [character 0 line 4]",
"error": "Bad Request",
"status": 400,
"timestamp": 1446044909025
}
There are several problems with the request:
1) Unterminated string at 61
means that the JSON is not correctly formatted. Not sure how here the newline characters are encoded, but I suggest using \n
or send the JSON from file using -d @template.json
2) there is not endpointType
field in the JSON, but type
3) visibility
should be send as query parameter and not as part of the JSON object.
4) you need to be authenticated before you submit a template for creation. In other words, you need to create a user, and then request for a token and submit the token using the token
parameter when creating a template.
Here is a valid cURL request
curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d @template-pieter.txt "http://api-dev.freme-project.eu/current/e-link/templates/?informat=application%2Fjson&outformat=application%2Fjson&token=YOUR_TOKEN"
Here is your template attached template-pieter.txt
hey Pieter, I was just reading https://github.com/freme-project/Documentation/issues/115 and realized that point 2) and 3) are not valid, so:
1) Unterminated string at 61
means that the JSON is not correctly formatted. Not sure how here the newline characters are encoded, but I suggest using \n or send the JSON from file using -d @template.json
2) endpointType
is correctly set and it is part of the JSON
3) visibility
is correctly set and it is part of the JSON
4) stays the same.
Sorry for the noise I just wasn't informed about the changes.
Sending the corrected template attached template-pieter.txt
@jnehring do you know about the first problem? Because I assume that when (new) users test the API using the documentation this should work, no?
The JSON in the code example is not correct. There are no newlines in JSON. Newlines are escaped with \n
in JSON.
We will handle this issue in freme-project/Documentation#125
@pheyvaer can you please try again? We updated the documentation.
@jnehring this works now. Is it also possible to provide an input field to add a token to the request?
You can find that field on the bottom of the full api documentation page. Its a new feature.
I get a 400 when trying the provided example: