Skip to main content

Posts

Showing posts from October, 2012

How to attach an image as an attachment to the parent object using REST API of force.com when image come from client as base64 encoded Text in JSON request

The REST API's offered by the force.com platform has matured lot since previous three versions and this makes it exiting for the integration with other system supporting JSON in their API's
I was reading an article by Sandeep Bhanot(I personally feel he is one of the best in salesforce evangelism) on the platform's ability to deserialise the base 64 encoded image and also decode it .
Here is the link to the article Using Binary Data With REST
Unfortunately my client app(ipad app)was using older version of REST kit that comes along with SDK and they feared upgrading to the newer version
Hence the design was altered to pass the base64 encoded text in the JSON request.Following is the code snippet that we need to decode the binary base 64 encoded image and attach as an attachment to the necessary parent object in sfdc
@RestResource(urlMapping='/Callmanagement/v1/*') global with sharing class SFA_DoctorsignPoc { @HttpPost global static String attachdoctorsSign(Str…