4

I have a REST webservice which inserts multiple records into custom objects. I am executing it on workbench using the following request:

{"req" : {"tickets": [{ "External_TicketID__c" :1853, "Date_Time__c": "9/13/2015 20:30" }, { "External_TicketID__c" :26554, "Date_Time__c": "9/13/2015 22:30" } ]}}

I am getting the following JSON Parse error.What am I doing wrong?

message: Cannot deserialize instance of datetime from VALUE_STRING value 9/13/2015 02:30 AM at [line:3, column:37] errorCode: JSON_PARSER_ERROR

1
  • Did you try passing in this format 2007-04-05T12:30-02:00 ? Feb 11, 2016 at 18:06

1 Answer 1

4

Assuming the field is a date-time field, you've the wrong format. It should be in standard ISO 8601 format:

{"req" : {"tickets": [{ "External_TicketID__c" :1853, "Date_Time__c": "2015-09-13T20:30:00.000Z" }, { "External_TicketID__c" :26554, "Date_Time__c": "2015-09-13T22:30:00.000Z" } ]}}

As a side note, make sure that External_TicketID__c is indeed a number field, or you'll get an error there, too.

3
  • I just tried deserializing a JSON string with the exact same format you have above. I received the following error: System.JSONException: Cannot deserialize instance of date from VALUE_STRING value 2016-12-05T16:19:44.000Z..... Check out the DateTime format: 2016-12-05T16:19:44.000Z - what's off?
    – ZAR
    Mar 30, 2016 at 17:24
  • 1
    @ZAR I know this is years old at this point but in case anyone else comes across this, your error seems to point to date not datetime. In other words, you would need to cut off the time part in the string or convert the field to a datetime field. Jan 9, 2023 at 19:50
  • 2
    @MatthewGreen good catch! I've been waiting 2,477 days for an answer! I can finally go home!
    – ZAR
    Jan 10, 2023 at 20:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .