function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rahul AlladaRahul 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.

SwethaSwetha (Salesforce Developers) 
HI Rahul,
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