• rahma salesforce
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Hi,
I'm invoking a Rest Webservice from my developer org,
the issue is I can't read the HTTP Response as it is not proper json
this is the form of the response:
[  
   {  
      "attributes":{  
         "type":"Account",
         "url":"/services/data/v36.0/sobjects/Account/001580000054G7bAAE"
      },
      "Id":"001580000054G7bAAE",
      "Name":"357",
      "Phone":"1233800"
   },
   {  
      "attributes":{  
         "type":"Account",
         "url":"/services/data/v36.0/sobjects/Account/001580000054G7cAAE"
      },
      "Id":"001580000054G7cAAE",
      "Name":"358",
      "Phone":"1233801"
   },
   {  
      "attributes":{  
         "type":"Account",
         "url":"/services/data/v36.0/sobjects/Account/001580000054G7dAAE"
      },
      "Id":"001580000054G7dAAE",
      "Name":"359",
      "Phone":"1233802"
   },
   {  
      "attributes":{  
         "type":"Account",
         "url":"/services/data/v36.0/sobjects/Account/001580000054G7eAAE"
      },
      "Id":"001580000054G7eAAE",
      "Name":"360",
      "Phone":"1233803"
   },
   {  
      "attributes":{  
         "type":"Account",
         "url":"/services/data/v36.0/sobjects/Account/001580000054G7fAAE"
      },
      "Id":"001580000054G7fAAE",
      "Name":"361",
      "Phone":"1233804"
   }
]

I'm using  wrapper classes to extract the response as following:
public class Response{
        public List<Account> accounts{get;set;}
}
    
 public class Account{
        public List<Attribute> attributes;  
        public String Id;
        public String Name;
        public String Phone;
   }   
   public class Attribute{
        public String type;
        public String url;
        
   }
but when trying to deserialize the reponse as the code below
Response response = (Response) JSON.deserialize(jsonResponse, Response.class);
I have this error:
System.JSONException: Malformed JSON: Expected '{' at the beginning of object
Is this because the HTTP response is not json ? it is specified in the content type though,
how can I convert the httpresponse body to json please ?


 
Hi,
I want to insert contacts from a developer org to another developer org
using rest api and a batch apex
do I need to set an endpoint for the developer org and use HTTP request/response ?
is there any useful links please ? 
Hi,
I want to load 20000 accounts and 20000 contacts in my developer org but I get: 
storage limit exceeded error ..
I deleted all the other data present in the org and still have this issue
is there a way to have this amount of data ( 20000 accounts and 20000 contacts) 
in a developer org  please ?
Hi,
I'm invoking a Rest Webservice from my developer org,
the issue is I can't read the HTTP Response as it is not proper json
this is the form of the response:
[  
   {  
      "attributes":{  
         "type":"Account",
         "url":"/services/data/v36.0/sobjects/Account/001580000054G7bAAE"
      },
      "Id":"001580000054G7bAAE",
      "Name":"357",
      "Phone":"1233800"
   },
   {  
      "attributes":{  
         "type":"Account",
         "url":"/services/data/v36.0/sobjects/Account/001580000054G7cAAE"
      },
      "Id":"001580000054G7cAAE",
      "Name":"358",
      "Phone":"1233801"
   },
   {  
      "attributes":{  
         "type":"Account",
         "url":"/services/data/v36.0/sobjects/Account/001580000054G7dAAE"
      },
      "Id":"001580000054G7dAAE",
      "Name":"359",
      "Phone":"1233802"
   },
   {  
      "attributes":{  
         "type":"Account",
         "url":"/services/data/v36.0/sobjects/Account/001580000054G7eAAE"
      },
      "Id":"001580000054G7eAAE",
      "Name":"360",
      "Phone":"1233803"
   },
   {  
      "attributes":{  
         "type":"Account",
         "url":"/services/data/v36.0/sobjects/Account/001580000054G7fAAE"
      },
      "Id":"001580000054G7fAAE",
      "Name":"361",
      "Phone":"1233804"
   }
]

I'm using  wrapper classes to extract the response as following:
public class Response{
        public List<Account> accounts{get;set;}
}
    
 public class Account{
        public List<Attribute> attributes;  
        public String Id;
        public String Name;
        public String Phone;
   }   
   public class Attribute{
        public String type;
        public String url;
        
   }
but when trying to deserialize the reponse as the code below
Response response = (Response) JSON.deserialize(jsonResponse, Response.class);
I have this error:
System.JSONException: Malformed JSON: Expected '{' at the beginning of object
Is this because the HTTP response is not json ? it is specified in the content type though,
how can I convert the httpresponse body to json please ?