HttpRetriever to Upload file (body needs JSON and mutipart encoded)

Hello, 

I'm trying to use the HttpRetriever node to send a post request to a file storage service (Box). The API specifies that you need to send in the body a JSON string with parameters for the upload, as well as the actual multi-part encoded binary file as well. 

In the node so far, I've got my auth header set, the multipart entity set as well as its generated content type string. But I don't see a way to add the JSON to the body as well, causing me to get a bad request when executing the API. 

Here is the sample cURL request provided by the API provider: 

curl https://upload.box.com/api/2.0/files/content \
  -H "Authorization: Bearer ACCESS_TOKEN" -X POST \
  -F attributes='{"name":"tigers.jpeg", "parent":{"id":"11446498"}}' \
  -F file=@myfile.jpg

Cheers!

Chris

Hi Chris,

I currenty do not have an example at hand, but from my memories you can only supply Binary Cells to the Multipart node. So make sure to convert both the JSON and the image to binary data and it should work. (using String to Binary Object and Files to Binary Object nodes ... I think they are in the "KNIME Filehandling" package).

HTH,
P.

Oh thanks! Then that just gets encoded into one entity. I'll give that a try today. - C

Did this work for you?

I want to do something similar (though I am encountering other types of problems, e.g. the authentication, but that is a different story)