samedi 16 septembre 2017

read array of objects from http request in Java

In my web service endpoint in Java I need to read array of objects from http request. I was able to read simple parameters but get get 500 when trying to read as follows

// caller passes child versions. Routine updates all versions.

    .post("/xxxx/registerSoftware",promise( (req, deferred) -> {
        SparqlClient client = req.require(SparqlClient.class);
        HashMap<String,Object> body = req.body().to(HashMap.class);

The curl command run:

curl -H "Content-Type: application/json" -X POST -d ' 
[ { "id": "http://ift.tt/2y6f6cM", "sys:description": "MariaDB Server 10.1", 
"sys:fqcn": "mariadbsdfgdfgrdfgdfg", "sys:moduleName": "mariadb", "ver:revision": "", "ver:servicePack": "", "version": "10.1", 
"skos:altLabel": "MariaDB Server 10.1", "skos:prefLabel": "MariaDB Server 10.1" }, 
{ "id": "http://ift.tt/2x6zcUT", "sys:description": "MariaDB Client 10.1", 
"sys:moduleName": "mariadb-client...pending...", "sys:packageName": "MariaDB-client", "ver:revision": "", 
"ver:servicePack": "", "version": "10.1", "skos:altLabel": "MariaDB Client 10.1", "skos:prefLabel": "MariaDB Client 10.1" } ] ' 
http://localhost:9090/xxxx/registerSoftware

Aucun commentaire:

Enregistrer un commentaire