user3827132 user3827132 -4 years ago 577
HTTP Question

Pentaho HTTP Post using JSON

I'm brand new to Pentaho and I'm trying to do the following workflow:

  • read a bunch of lines out of a DB

  • do some transformations

  • POST them to a REST web service in JSON

I've got the first two figured out using an input step and the Json Output step.

However I have two problems doing the final step:

1) I can't get the JSON formatted how I want. It insists on doing
when I just want
. This isn't a big deal - I can work around this since I have control over the web service and I could relax the input requirements a bit. (Note: this page gives an example for the output I want by setting
no. rows in a block=1
and an empty JSON block name, but it doesn't work as advertised.)

2) This is the critical one. I can't get the data to POST as JSON. It posts as
, where the key is the name I specify in the HTTP Post field name (on the 'Fields' tab) and the value is the encoded JSON. I just want to post the JSON as the request body. I've tried googling on this but can't find anyone else doing it, leading me to believe that I'm just approaching this wrong. Any pointers in the right direction?

Edit: I'm comfortable scripting (in Javascript or another language) but when I tried to use XmlHttpRequest in a custom javascript snippet I got an error that XmlHttpRequest is not defined.


Answer Source

This was trivial...just needed to use the REST Client ( instead of the HTTP Post task. Somehow all my googling didn't discover that, so I'll leave this answer here in case someone else has the same problem as me.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download