13.07.2015 Views

Database.com REST API Developer's Guide - Salesforce.com

Database.com REST API Developer's Guide - Salesforce.com

Database.com REST API Developer's Guide - Salesforce.com

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Using <strong>REST</strong> <strong>API</strong> ResourcesInsert or Update (Upsert) a Record Using an External IDResponseSuccessful response:{}"id" : "a01D0000001pPvHAAU","errors" : [ ],"success" : trueThe response body is empty. HTTP status code 201 is returned if a new record is created.Error responsesIncorrect external ID field:{}"message" : "The requested resource does not exist","errorCode" : "NOT_FOUND"For more information, see Status Codes and Error Responses on page 78.Upserting Existing RecordsThis example uses the PATCH method to update an existing record. It assumes that an external ID field,“customExtIdField__c,” has been added to Widget__c and a Widget__c record with a customExtIdField value of 11999 exists.The request uses updates.json to specify the updated field values.Example for upserting a record that already existscurlhttps://na1.salesforce.<strong>com</strong>/services/data/v20.0/sobjects/Widget__c/customExtIdField__c/11999-H "Authorization: Bearer token" -H "Content-Type: application/json" -d @updates.json-X PATCHExample JSON request body updates.json file{}"Widget_Cost__c" : 5.75JSON example responseHTTP status code 204 is returned if an existing record is updated.Error responsesIf the external ID value isn't unique, an HTTP status code 300 is returned, plus a list of the records that matched thequery. For more information about errors, see Status Codes and Error Responses on page 78.If the external ID field doesn't exist, an error message and code is returned:{}"message" : "The requested resource does not exist","errorCode" : "NOT_FOUND"38

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!