You need to sign in to do that
Don't have an account?
Nandu
Json Deserialization failed on token 'null' and has left off in the middle of parsing a row. Will go to end of row to begin parsing the next row
String jsonText = '{"Data": [{"attributes": {"type": "Contact","url":"/services/data/v35.0/sobjects/Contact/0036100000JUXKkAAP"},"Email":"positi@gmail.com","Description": "","Phone":"9999999","LastName": "sasumi"},{"attributes": {"type": "Contact","url":"/services/data/v35.0/sobjects/Contact/0036100000JUXKkAAP"},"Email":"edge@gmail.com","Description": "","Phone":"88888","LastName": "pavanTL"}]}'; Map<String, Object> deserialized = (Map<String, Object>)JSON.deserializeUntyped(jsonText); List<Map<String, Object>> data = new List<Map<String, Object>>(); for (Object instance : (List<Object>)deserialized.get('Data')){ data.add((Map<String, Object>)instance); } String dataSerialize=JSON.serialize(data); System.debug('dataSerialize...'+dataSerialize); try { SObject customObject = (SObject)JSON.deserialize(dataSerialize, Sobject.class); Database.upsert(customObject); System.debug(' customObject...: '+customObject); } catch(Exception ex) { System.debug(' @@@@@ Don\'t visible '+ex.getMessage()); }
Try below code.
regards
All Answers
Try below code.
regards
DML on generic List<SObject> only allowed for insert, update or delete
That is a limitation in the platform. it is better if you can provide the Id attribute also inside the json string and try with update.
then,
---------------------------
update(dataFields);
regards
Thank you @Sampath Suranji
How can it be when it is inserted ?, I have tried to create several records but I get the following error:
[
{
"message": "Json Deserialization failed on token 'null' and has left off in the middle of parsing a row. Will go to end of row to begin parsing the next row",
"errorCode": "INVALID_FIELD"
}
]
In postman
[{"Codigo__c":403.0,"Contrato__r":{"Id_contrato_JDE__c":200870468.0},"Costo__c":0.00,"Descripcion__c":"TOP-1 PINTURA ELASTOMERICA EN FACHADAS.- BLANCO BLANCO/REPOSE GRAY/DAPPER TAN ","Eliminado__c":false,"Enviado_JDE__c":false,"Fecha_de_creacion__c":"2020-05-01T18:39:09","Financiamiento__c":"a0G1h000002fKRzEAM","GrupoId__c":2.0,"Monto__c":0.00,"Name":null,"Nombre_del_Acabado__c":"TOP-1 PINTURA ELASTOMERICA EN FACHADAS.- BLANCO BLANCO/REPOSE GRAY/DAPPER TAN ","Nombre_Grupo__c":"","Promocion__c":false,"Descuento__c":false,"Cotizacion__c":"a0B1h0000025dI0EAI","Numero_de_Cita__c":null},{"Codigo__c":404.0,"Contrato__r":{"Id_contrato_JDE__c":200870468.0},"Costo__c":0.0,"Descripcion__c":null,"Eliminado__c":true,"Enviado_JDE__c":false,"Fecha_de_creacion__c":"2020-05-01T18:39:09","Financiamiento__c":"a0G1h000002fKRzEAM","GrupoId__c":2.0,"Monto__c":0.0,"Name":null,"Nombre_del_Acabado__c":"PINTURA DE FACHADAS- TOP-1 - APLICACIÓN DE PINTURA A CRITERIO DEL CONSTRUCTOR","Nombre_Grupo__c":null,"Promocion__c":false,"Descuento__c":false,"Cotizacion__c":"a0B1h0000025dI0EAI","Numero_de_Cita__c":null}]
when I send a record at the same time it does not give an error but when I send several records it sends the error message