0
votes

I am working with Mule 3.8 and need to send a file to target REST service in json (base64).

I am trying to find options but any of them is not working. I have a file in my payload or else I can read it from file.

Here is my approach. Generate JSON in Dataweave transformation using script and add the file content (transform to base64). This will give us JSON in required format. However we need to add file content in JSON too (sample JSON is below). We can get the file content using #[message.inboundAttachments['file'].dataSource.content] in payload, but not sure how to pass the same to dataweave.

> { "form_data": { "name": 'xyz' }, "files": [ { "fileid": "id1",
> "filedata": "base64 file data" }] }
1
It is not clear what you ask for. You have your data as field filedata value and this is one piece of data. Like BLOB or something similar. Dataweave operates with it as one piece. Is your goal to extract data from this BLOB? Then transform it from base64, define metadata and use it. That's 3 steps in the flow. Is it what you want?Alex

1 Answers

0
votes

(Posted solution on behalf of the OP).

I used Custom java transformer and fetched all data from MuleMessage object. Created json value and set it back in payload.