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> ResourcesWorking with RecordsIf there were changes to Merchandise__c made after July 3rd, 2013, the response body would contain the metadata forMerchandise__c. See Get Field and Other Metadata for an Object for an example.Working with RecordsYou can use <strong>REST</strong> <strong>API</strong> to work with records in your organization.The examples in this section use <strong>REST</strong> <strong>API</strong> resources to create, retrieve, update, and delete records, along with otherrecord-related operations.Create a RecordUse the SObject Basic Information resource to create new records. You supply the required field values in the request data,and then use the POST method of the resource. The response body will contain the ID of the created record if the call issuccessful.The following example creates a new Widget__c record, with the field values provided in newwidget.json.Example for creating a new Widgetcurl https://na1.salesforce.<strong>com</strong>/services/data/v20.0/sobjects/Widget__c/ -H "Authorization:Bearer token -H "Content-Type: application/json" -d @newwidget.json"Example request body newwidget.json file for creating a new Widget{}"Name" : "test"Example response body after successfully creating a new Widget{}"id" : "a01D000000IqhSLIAZ","errors" : [ ],"success" : trueUpdate a RecordYou use the SObject Rows resource to update records. Provide the updated record information in your request data and usethe PATCH method of the resource with a specific record ID to update that record. Records in a single file must be of thesame object type.In the following example, the Widget Cost within a Widget is updated. The updated record information is provided inpatchwidget.json.Example for updating a Widget custom objecthttps://na1.salesforce.<strong>com</strong>/services/data/v20.0/sobjects/Widget__c/a01D000000INjVe -H"Authorization: Bearer token" -H "Content-Type: application/json" -d @patchwidget.json-X PATCH34

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

Saved successfully!

Ooh no, something went wrong!