• lcampos
  • NEWBIE
  • 5 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies

Hi,

I have a controller which makes HTTP callouts to a J2EE webapp, the callout returns a list of JSON objects.

I need to retrive values from this object and insert it into salesforce object, there is no VF page for this. I get the following list in response to my call.

 

[{"quoteId":"364926","baseModelName":"e-Studio Color Copier - Tandem LCF","accessoryNames":["Finier Rail"],"baseModelCost":20000.0,"skuNumber":"ESTU0CT"},{"quoteId":"364926","baseModelName":"e-Studio Copier - 4 Drawer","accessoryNames":["50 Sheet Stapling Finisher"],"baseModelCost":10000.0,"skuNumber":"ESTU0C"}]
 
To parse above list I first created an apex class as below
 
public class PrimaryQuoteObj {

       public String quoteId;
       public String baseModelName;
       public List<String> accessorySKUs;
       public Double baseModelCost;
       public String skuNumber;
}

and then tried to parse the list in the controller using the above class like below.
global class ExtCalloutController {

   WebService static void getPrimaryQuoteDetails(String id) {
          HttpRequest req = new HttpRequest(); 
        //Set HTTPRequest Method
       req.setMethod('GET');
   
       //Set HTTPRequest header properties
       req.setHeader('Connection','keep-alive');
       req.setEndpoint('http://cxyz.row.com/myApp/getPrimaryDetails.htm?qId='+id);
       Http http = new Http();
       try {
               //Execute web service call here     
                HTTPResponse res = http.send(req);  
                System.debug('Response Body = ' + res.getbody());
                PrimaryQuoteObj priQuotedetails =(PrimaryQuoteObj)System.JSON.deserialize(res.getbody(), PrimaryQuoteObj.class);
                //Helpful debug messages
                System.debug(res.toString());
                System.debug('STATUS:'+res.getStatus());
                System.debug('STATUS_CODE:'+res.getStatusCode());

        } catch(System.CalloutException e) {
            //Exception handling goes here....
        }  
       // return null;   
    }
}
    
 
When parsing the JSON list I get the exception:
System.JSONException: Malformed JSON: Expected '{' at the beginning of object
 
I understand that this is because it's a list of JSON objects, trying to figure out how to loop through this list. I am a total newbie to salesForce and apex and any help is appreciated.
  • April 18, 2013
  • Like
  • 0

Hi all,

 

You are gonna like this one!

 

I am getting an error on Eclipse 3.4.2 that restricts me to save, synchronize and/or deploy my project. It reads:

 

"Unable to fetch and save Force.com components to project:

 The changes you requested require salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for the previous action to finish, then try again later. (ALREADY_IN_PROCESS)"

 

Has anyone seen this error before? I have wait for 15 minutes (my max waiting capacity :( ), tried to refresh, deploy, save... but this error is not letting me go anywhere.

 

Suggestions are welcome

 

Alex

  • February 16, 2010
  • Like
  • 0
Does this error mean that the ip address is not whitelisted ? 
 
Thanks,
 
Bill
forceAmp.com