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
Robert JakubovRobert Jakubov 

Creating a Case with custom filed

Hello friends,

i am trying to create a Salesforce Case using the REST api (sobject, etc) and one of my fields in the Case is a custom object (Social_Message__c)  which i configured as a Case custom field.  Now when I am doing a POST call to the /sobjects/Case/ SFDC endpoint, I get the following exception:
'[{"message":"Cannot deserialize instance of reference from START_OBJECT value { or request may be missing a required field at [line:1, column:490]","errorCode":"JSON_PARSER_ERROR"}]'.

The JSON payload that I am passing is:

{'AssetId': None, 'Social_Message__c': {'Private_Message__c': False, 'Processed__C': False, 'Social_Platform__c': u'Facebook', 'Body__c': 'test'}, 'Type': 'Customer Support', 'Status': 'New', 'Reason': None, 'Origin': 'Web', 'SuppliedName': None, 'SuppliedEmail': None, 'Language__c': 'English', 'ParentId': None, 'Subject': u'confirm pub fb msg', 'AccountId': None, 'ContactId': u'003c000000iQNDaAAO', 'SuppliedCompany': None, 'IsEscalated': False, 'Product__c': None, 'Country__c': 'United States', 'SuppliedPhone': None, 'Priority': 'Medium'}

Any ideas what might be the issue?

thanks 
Rob
Daniel BallingerDaniel Ballinger
I'd try running your JSON payload through a validator. Try https://jsonformatter.curiousconcept.com/ for a start.

It identified a number of problems.
  1. Strings should be delimited with double quotes, not single quotes (http://stackoverflow.com/q/14355655/54026)
  2. I a couple of locations the strings are prefixed with a rogue u. E.g. 'Subject': u'confirm pub fb msg'
  3. I suspect your None values should be null.
  4. Boolean values should be lower case. E.g. false
Try something like the following:
{
   "AssetId":null,
   "Social_Message__c":{
      "Private_Message__c":false,
      "Processed__C":false,
      "Social_Platform__c":"Facebook",
      "Body__c":"test"
   },
   "Type":"Customer Support",
   "Status":"New",
   "Reason":null,
   "Origin":"Web",
   "SuppliedName":null,
   "SuppliedEmail":null,
   "Language__c":"English",
   "ParentId":null,
   "Subject":"confirm pub fb msg",
   "AccountId":null,
   "ContactId":"003c000000iQNDaAAO",
   "SuppliedCompany":null,
   "IsEscalated":false,
   "Product__c":null,
   "Country__c":"United States",
   "SuppliedPhone":null,
   "Priority":"Medium"
}