I have created REST which fetching the data from pardot and displaying it on the vf page. It is working fine. But I need to store this data in the custom object's corresponding fields on the vf page. As of now I bind the wrapper class on the page.
Suppose, I have FirstName and LastName fields in the wrapper class which I need to store in the First_Name__c and Last_Name__c fields on the custom object from wrapper class.
Here is my REST class:
{{
wrapper = (PardotProspectWrapper)JSON.deserialize(res.getBody(), PardotProspectWrapper.class);
system.debug('******Wrapper*****'+wrapper); // getting response here
//iterating wrapper response and adding to Pardot_Prospect__c object
List<Pardot_Prospect__c> csbs = new List<Pardot_Prospect__c>();
for (PardotProspectWrapper w : wrapper) { // Error - Loop must iterate over collection: PardotProspectWrapper
csbs.add(w.csb);
}
insert csbs;
}
//wrapper created for custom object Pardot_Prospect__c
public class PardotProspectWrapper{
public Pardot_Prospect__c csb {get;set;}
public result result{get;set;}
public class result{
public list<prospect> prospect{get;set;}
}
public class prospect{
public String first_name{get;set;}
public String last_name{get;set;}
}
}
Can somebody please tell me how can I achieve it. it would be great help.
Thank you in advance.