1

i am trying to build an app using salesforce as backend. I want to access the attachment in the cases. i am able to see the attachment using the workbench :-

/services/data/v29.0/sobjects/Attachment/00Po0000001rTqKEAU/Body-H "Authorization token:bearer token"

I am using this but i am unable to get the contents of the body... Its giving just a single binary 2 when it actually has 43567 as the content of the attachment.

LEt me know if u anyone knows this

closed as off-topic by superfell, Vamsi Krishna, Eric, Boris Bachovski, Keith C Nov 4 '15 at 10:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – superfell, Vamsi Krishna, Eric, Boris Bachovski, Keith C
If this question can be reworded to fit the rules in the help center, please edit the question.

  • post your code. – superfell Dec 23 '14 at 18:06
0

I simply used .toString() and I am able to read the data in the text file attached.
Here is the response:
Blob lstAttach = [Select Body from Attachment where ID = '00P9000000IUVOE'][0].Body; system.debug(lstAttach.toString());
29.0 APEX_CODE,DEBUG Execute Anonymous: Blob lstAttach = [Select Body from Attachment where ID = '00P9000000IUVOE'][0].Body; Execute Anonymous: system.debug(lstAttach.toString()); Execute Anonymous: 00:01:14.045 (45789804)|EXECUTION_STARTED 00:01:14.045 (45802522)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex 00:01:14.087 (87858375)|ENTERING_MANAGED_PKG| 00:01:14.087 (87952246)|ENTERING_MANAGED_PKG| 00:01:14.087 (87962341)|USER_DEBUG|[2]|DEBUG|4663554 00:01:14.088 (88011818)|CODE_UNIT_FINISHED|execute_anonymous_apex 00:01:14.089 (89231600)|EXECUTION_FINISHED

Not the answer you're looking for? Browse other questions tagged or ask your own question.