I have a below array of objects in my LWC
const lineItemsToUpdateArray = [{"id":"a2323000000EWeRAAW","Licensed_User__c":"0032H00002HWXvzQAH","attributes":{"type":"Proposal_Line_Item__c","url":"/services/data/v57.0/sobjects/Proposal_Line_Item__c/a2323000000EWeRAAW"}}]
passing the above array to apex
await updateLineItems({lineItemsToUpdateArray })
passing the same JSON to apex
Apex code:
public static void updateLineItems(sObject[] lineItemsToUpdateArray) {
update lineItemsToUpdateArray;
}
It throws below error
{"status":500,"body":{"message":"Unable to read
SObject"},"headers":{},"ok":false,"statusText":"Server
Error","errorType":"fetchResponse"}
Could someone please point me to the right direction?
Best Answer
To send an SObject from LWC to Apex, you need to use the following format:
(Note:
Id
notid
)