0

I'm trying to create a Kettle transformation to populate my Spark Java (sparkjava.com) server,deployed on heroku, instead of inserting the data by hand. The code on the server side to take care of a Post request on the route "/insert" is the following :

post("/insert", (req, repl) -> {
        String json=new String(req.bodyAsBytes());
        /*Some processing...*/
        MyRecordList myRL=MyRecordList.fromJsonString(json);
        for (MyRecord mr : myRL.getRecords()) {
            Instance inst = mr.toWekaInstance(trainset);
            trainset.add(inst);
        }       
        return "ok";
    });

With this I believe the whole body will be the JSON of a MyRecordList object.

On the Pentaho side there's the HTTP Post step and the location definition is straightforward. However I'm stuck on how to specify a JSON string as the whole body of the post request and sending it to the server. According to the Heroku logs the request generated by Pentaho doesn't even reach the server. Here are the parameters I put there: General Options Fields

Can anyone please enlighten me, or show me other way to populate the server, that follows the restrictions above?

4

1 回答 1

0

您将 json 内容作为标头而不是在有效负载中发送,这将是正确的。此外,我没有在您的屏幕截图中确定您已将请求的内容类型设置为 json,可能它是以 html 形式发送的。我从来没有使用过这个工具 Pentaho,但我建议你使用这个 Chrome 扩展,在我看来它是最简单的 Rest Api 测试器。

于 2016-05-17T13:56:08.113 回答