You need to sign in to do that
Don't have an account?
Rahul Allada
System.JSONException: Nested object for polymorphic foreign key must have an attributes field before any other fields.
My mock body looks like :
'{"totalSize": 1, "done":true, "nextRecordsUrl":"WWW.testurl.com","records":[{"Name":"Fund1", "aduro__Date_of_Inception__c":"2011-10-09 00:00:00", "Accept_ACH_Payments__c":true,"ACH_Public_Key__c":"pk_sandbox_MTU4MmJhMDgtMTU4OC00YmVh","ACH_Secret_Key__c" :"sk_sandbox_OTc0ZTVkMzQtYmM5Mi00MWU5"}]}'And my wrapper looks like this:
public class QueryResponse { public Integer totalSize {get; set;} public Boolean done {get; set;} public String nextRecordsUrl { get; set; } public List<SObject> records {get; set;} }
The SObject in my case is fund__c.
When i use i am getting the error as System.JSONException: Nested object for polymorphic foreign key must have an attributes field before any other fields.
Can you try the approach mentioned in https://salesforce.stackexchange.com/questions/131433/apex-rest-request-requires-attributes-field
According to the JSON documentation(https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm):
Object deserialize(String jsonString, System.Type apexType)
Deserializes the specified JSON string into an Apex object of the specified type.
If this information helps, please mark the answer as best. Thank you