Pentaho

 View Only

 Post Request with JSON payload

Lisa Carpenter's profile image
Lisa Carpenter posted 04-24-2024 09:54

I'm very new to Pentaho, using 9.4 community edition.

I'm trying to do a post request with a JSON payload on a REST API. I've gathered from other forum posts, that the correct way to do this is with the HTTP post connector, not the REST one. So my setup is like this.

Modifide Java Script has:

var json = {
    "key1": value1,
    "key2": "value2"
};

data = JSON.stringify(json);

And my fields pane in the HTTP post looks like this

The web service is responding that the format of my request body can't be parsed. The JSON I'm using works perfectly when I use it in Postman. I'm pretty sure my error is in my Java Script. Is stringify the right thing to be doing? I have tried using the raw JSON and that has not been successful either.