I want to use the standard Force.com REST API to create a case remotely from another Salesforce instance in my instance. I want to populate two fields on creation: "Subject" and "txt_UserId__c". Because the source org doesn't have the case object, I wrote a custom class that is populated from inputfield values on a visualforce page:
public class CaseMap {
public String Subject {get; set;}
public Id txt_UserId__c {get; set;}
}
Unforunately the property "txt_UserId__c" is not allowed. This means I have to rename it to something else:
public class CaseMap {
public String Subject {get; set;}
public Id UserId {get; set;}
}
But this means, when serializing the class into JSON, one of the field names (i.e., 'UserId'), does not match the API field name that is expected on the target org.
What I did so far is a simple JSON string find and replace operation. But I am sure there must be a more elegant and less fault-prone way to change field names, for example include a mapping table in the serialization or so.
Any ideas?
Thanks!