I have a boomi process which takes the file content and send it to salesforce to create attachment. But attachment is blank.

Here is my code:

Attachment attach = new Attachment();
attach.contentType = 'image/png';
attach.name = 'test.png';
attach.parentId = '0010H00002DW2Ds';
attach.body = EncodingUtil.base64Decode(jsonStr);
insert attach;

Attachment is inserted but there is no content inside. Is there anything I am doing wrong.

Thank you, Thiru

  • What is the File type here?
    – Saroj Bera
    Mar 8 at 7:48
  • 1
    I have answered a similar question here, please check salesforce.stackexchange.com/questions/180211/…
    – Saroj Bera
    Mar 8 at 7:49
  • 1
    As I see the base64 is of the image, so you need to set the file type as 'image/png' att.contentType = 'image/png'; Mar 8 at 7:51
  • I have updated my new code in my question. But its still showing empty content. may be my base64 data is wrong.? I took the content from already attached image. Attachment atts = [SELECT ID,Body,ContentType FROM Attachment WHERE ID = '00Pp000000FskcuEAB']; String body1 = EncodingUtil.base64Encode(atts.Body); Mar 8 at 8:13
  • Thank you @Saroj Bera Mar 9 at 1:57

1 Answer 1


This file looks like a legitimate PNG file fragment when saved and downloaded. Reading through the file, we see:

tag length data
Magic 8 iVBORw0KGgo= // PNG HEADER
IHDR 13 Width = 1678, Height = 800, Bit Depth = 8, Color Type = 6, Compression Method = 0, Filter Method = 0, Interlace Method = 0
sRGB 1 0
gAMA 4 45455
pHYS 9 X = 5669, Y = 5669, Unit = Meters
IDAT 255 Pixel data 165 bytes long

Here the file trails off. There should be an IEND specifying the end of the image, but it doesn't exist. My conclusion is that the file is a fragment of what would be a valid PNG, but the rest of the file is missing.

  • Its working finally. The body content was invalid Mar 9 at 1:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .