function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dasari123dasari123 

Soql query foe attachment on case object

Hi,
 I wrote a soql to retrive the attachment from case object ,it is working fine ,but i can't see the ciontent of the attachment ,how can i retrive the content of the body through SOQl, or any possibility to download the attachment through SOQL

 My Query is
  SELECT ParentId, name,body
FROM Attachment
WHERE parentId IN (
    SELECT Id FROM Case ) limit 100

O/P:
"/services/data/v30.0/sobjects/Attachment/00PZ00000015EJqMAM/Body" this what i got as body how can i know the content
sfdc_ninjasfdc_ninja
Something like this should work


string attachString = attachment.body.ToString();

Blob body = EncodingUtil.base64Decode(attachString);
string UTF8 = body.toString();
string finalBody = EncodingUtil.urlDecode(UTF8, 'UTF-8');

finalBody should now be the attachment in legible string form.