We are consuming a REST API which created an insert on Lead object. We want to enforce data integrity from the external application to salesforce so that any field level changes on the external application throws a compile error in the salesforce side. I know this can be done easily with SOAP but the question is how can we enforce a data contract between Salesforce and external application using REST API? Can we create a JSON object structure on the legacy application which would be referenced as an object in the salesforce side and data sent as a JSON Post? The goal is to enforce field level changes on both applications consistently instead of loose coupling which REST provides? Any thoughts? Buyan

2 Answers 2


Not sure exactly what you are planning, but any validation that you implement in Force.com, e.g. in a Validation Rule or Trigger, is enforced on all access, whether in the browser or via the SOAP or REST APIs.


An invalid xml/json request will return a 400 error to the calling application. This is the most of a "contract" that you can feasibly have with salesforce.com, because the service itself is compiled only when changes occur, not on each request. You could generate a WADL/WSDL that describes the contract between salesforce.com and your external system, but that would only cause a compilation error in your external application, not in salesforce.com.

  • Thanks for your reply. Since the data contract resides in the external application, is there a way to create the compilation error in salesforce so that we can get the modified changes and fix salesforce call out instead of external application? Do you have any sample code or links which describes the contract? Oct 29, 2013 at 13:36
  • Not for REST applications, unless you can manage to import a REST WSDL (which I don't think you can yet). But a simple change in the external system won't trigger a compilation error in salesforce.com anyways, because salesforce.com doesn't recompile code for no reason, and it has no way to dynamically load the contract and compile against it. You will, however, get an error that you could send an email for once a break occurs-- like I said, you'll get an appropriate error message from the system when the data no longer matches up correctly.
    – sfdcfox
    Oct 29, 2013 at 14:03

You must log in to answer this question.

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