Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
input response :
[{"attributes":{"type":"ContentVersion"},"ContentLocation":"S","ContentSize":1201,"VersionData":"/services/data/v65.0/sobjects/ContentVersion/068R500000HiP4AIAV/VersionData","VersionNumber":"1","Title":"sitertracker-logo","PublishStatus":"P","ContentBodyId":"05TR500000NUusMMAT","FileType":"PNG",
"ReasonForChange":"base 64"},{"attributes":{"type":"ContentVersion"},"ContentLocation":"S","ContentSize":42521,"VersionData":"/services/data/v65.0/sobjects/ContentVersion/0683z000008xk9fAAA/VersionData","VersionNumber":"1","Title":"Sitetracker Logo - Small (Transparent)",,"ReasonForChange":" base 65 code "}]bash-4.4$
response which i need to post to endpoint url:
json payload -------- {attachement1 : sitertracker-logo.png, attachement2 : Sitetracker Logo - Small (Transparent).png}
binary files ------------ sitertracker-logo.png & Sitetracker Logo - Small (Transparent).png files
currently there has reasonfor change column attribute contains Base 64 code .i will be getting multiple attachements there could 3, 4 ,5...now this i should construct one json and all the base 64 i should convert to binary and send it to endpoint url......finally one json payload with all attachments
in payload there is ReasonForChange":"base 64" here i will have base 64 code in this reason for change attribute
now i should construct one json with {attachement1: filename, attachment2: filename,attachment3 : filename}.............................adding this i should convert base 64 to binary files and attach it to restendpoint url in single transaction ,, iwant to use using Tretclient component.
the files are dynamic based on payload , we may get multiple attribute sets realted to document if there are 2 attachments, we will get 2 times the 'reason for change' column in that we will have different base 64 code.
Hello,
When sending JSON data with an image to a REST endpoint, Talend does not automatically convert or handle binary content.
If the image is provided as Base64:
It must be handled explicitly according to what the target API expects.
Talend will treat Base64 values as plain text unless you process them.
Implementation approach:
If the endpoint expects Base64 inside JSON:
Keep the image content as Base64
Build the JSON payload using tMap / tWriteJSONField
Send the request using tRESTClient with Content-Type: application/json
If the endpoint expects a binary file:
Decode the Base64 value in Talend (for example using java.util.Base64.getDecoder())
Send the request using tRESTClient or tHttpRequest configured for multipart/form-data
Attach the binary content as a file or request body part
Important notes:
JSON payloads cannot contain raw binary data; binary content must be Base64-encoded.
Talend does not implicitly transform Base64 strings into binary attachments.
The request structure must strictly match the API contract.
Best practice:
Confirm whether the endpoint expects Base64-encoded data or multipart binary content, and build the Talend job accordingly.
Thanks,
Gourav