global with sharing class DD_Rest_Test{

    global static Response getData() {
        Response resp;        
        RestRequest req = RestContext.request;
        Map<String, data> datapoints;
        data mydata;

            datapoints = new Map<String, data>();

            List <Map<String, data>> b = new List <Map<String, data>>();

            mydata = new data('a','b');

            mydata = new data('c','d');

            resp = new Response(b);
        catch(Exception ex){
            resp = new Response('Error line ' + ex.getLineNumber() + ': ' + ex.getmessage() + ' Reason: ' + ex.getCause(),204);
        return resp;
     Global class Response{
        Integer code;
        String Message;
        List <Map<String, data>> services;

        public Response( List <Map<String, data>> services){

            this.services = services;

        public Response(String Message, integer code){
            this.code = code;
            this.Message = Message;
            //this.id = null;

    Global class data{
        String url;
        String input;
        Bolb image,
        public data(String url, String input,Bolb image){
            this.url = url;
            this.input= input;

here is my rest API,i want to image along with some other data,can how i can achieve,,please help


You can store the image in Blob variable and then stringify it to JSON format the same for base64 format. Later you can deserialize and use the image. You can refer the below link.

How to save Base64 image data as salesforce attachment

  • you said like ,i can store image,do i have to store image url in bolb variable?1
    – Satya
    Oct 5 '16 at 10:27
  • assume that i have stored sample images in documents tab.and have to put that image in datapoints ,,it is a map.,,how can i achieve this,iam a fresher
    – Satya
    Oct 5 '16 at 10:33
  • No, not the URL, you can store the actual image the blob. After deserializing you can store the image in a blob. Or you can directly do request.requestBody = Blob.valueOf(jsonString); Oct 5 '16 at 10:36
  • Please refer the link which i have provided, you will get a better idea. Oct 5 '16 at 10:38
  • thanks ,,but iam not able to link that to my requirement.
    – Satya
    Oct 5 '16 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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