freme-project / pipelines

Apache License 2.0
0 stars 0 forks source link

Expected BEGIN_ARRAY but was STRING #6

Closed m1ci closed 9 years ago

m1ci commented 9 years ago

I get error:

{
    "timestamp": 1440054728619,
    "message": "java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $",
    "error": "Internal Server Error",
    "status": 500,
    "exception": "com.google.gson.JsonSyntaxException",
    "path": "/pipelining/chain"
}

Error stack trace:

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $
    at com.google.gson.Gson.fromJson(Gson.java:822)
    at com.google.gson.Gson.fromJson(Gson.java:775)
    at com.google.gson.Gson.fromJson(Gson.java:724)
    at com.google.gson.Gson.fromJson(Gson.java:696)
    at eu.freme.eservices.pipelines.requests.RequestFactory.fromJson(RequestFactory.java:137)
    at eu.freme.broker.eservices.Pipelines.pipeline(Pipelines.java:45)

The cURL command:

curl -v -d pipeline1.json -X POST -H "Content-Type: application/json" "http://localhost:8080/pipelining/chain"

with body (pipeline1.json):

[
    {
        "type": "POST",
        "endpoint": "http://api.freme-project.eu/current/e-entity/dbpedia-spotlight/documents",
        "parameters": {
            "language": "en",
            "prefix": "http://freme-project.eu/"
        },
        "headers": {
            "content-type": "text/plain",
            "accept": "text/turtle"
        },
        "body": "This summer there is the Zomerbar in Antwerp, one of the most beautiful cities in Belgium."
    },
    {
        "type": "POST",
        "endpoint": "http://api.freme-project.eu/current/e-link/documents/",
        "parameters": {
            "templateid": "3",
            "prefix": "http://freme-project.eu/"
        },
        "headers": {
            "content-type": "text/turtle",
            "accept": "text/turtle"
        }
    }
]
ghsnd commented 9 years ago

Hi Milan, I also tried it and it failed. But I saw that the body contents was "pipeline1.json". So then I added @ before the filename in the command (as explained in the curl man page):

curl -v -d @pipeline1.json -X POST -H "Content-Type: application/json" "http://localhost:8080/pipelining/chain"

This works (here). Can you try this and see if it works, and if so, close this issue? Thanks!

m1ci commented 9 years ago

oh, you are right, I've missed the @ sign. Thanks for the catch!

ghsnd commented 9 years ago

This reminds me that I have to return a proper error message if there is something wrong with the JSON though. Will look into that.

ghsnd commented 9 years ago

A somewhat better error message returns now.