2

I am trying to use HTTP Post to post the data by passing following Header and Body part,

Body:

  1. One image URL having file path. Type as 'File'
  2. Metadata in JSON format. Type as 'Text'

Headers:

Content-type = multipart/form-data

Authorization = Bearer 5412

Here is the screenshot of complete request, enter image description here

This is how I have setup the HTTP Post task in Pentaho, enter image description here

I found related post here using REST Client but this also didn't help: Pentaho HTTP Post using JSON

Really appreciate your help.

Community
  • 1
  • 1
NNaseet
  • 68
  • 1
  • 8

2 Answers2

0

I think the problem is that "Post a file" doesn't mean include a file in the request, but rather to get the entire request from that file.

I don't know the specifics of how the data should look in the Post request, but the rough approach should be:

  1. Pass the filename field to a Calculator step with the operation "Load file content to binary" to get a binary type field (ex: myimage)
  2. Base64 (or other) encode the data with a Javascript step like this:

var encString = new Packages.java.lang.String( Packages.org.apache.commons.codec.binary.Base64.encodeBase64( myimage ) );

  1. Wrap it in some content-type string indicating the encoding
  2. Include the field in your request.
Cyrus
  • 2,135
  • 2
  • 11
  • 14
0

There is a patch on https://jira.pentaho.com/browse/PDI-14743 to enable proper binary transfer instead of String when using Rest Client.