---
schema_version: "1"
id: dc737dab36cc22b553309c680b61711da29caa3a427f4a91516b13145249b751
title: "Step Three: Walk Through the Sample Code"
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/api-rest/guides/quickstart/quickstart-code.md
canonical_url: https://developer.salesforce.com/docs/platform/api-rest/guide/quickstart-code.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: dacbc8ec548b168f4f843e7dfe4d197145af4b242d8bda4baa0c1195436efa71
products:
  - REST API Developer Guide
  - Platform Developer Content
---

# Step Three: Walk Through the Sample Code

To access different types of resources in Salesforce, make a series of REST requests. Before you try these examples, make sure to complete the prerequisites and obtain an access token in Step 1 of this Quick Start.

You can copy and paste these examples to send them with cURL. But first replace MyDomainName in the base URI with your Salesforce domain. For information on the anatomy of a REST request, see [REST Resources and Requests](https://developer.salesforce.com/docs/platform/api-rest/intro/intro-rest-resources.md).

## Get the Salesforce Version

To retrieve information about each available Salesforce version, submit a [Versions](https://developer.salesforce.com/docs/platform/api-rest/resources/resources-versions.md) request. In this case, the request doesn’t require authentication.

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/
```

The output from this request, including the response header, specifies all valid versions. Your result can include more than one value.

```nolang
Content-Length: 88 
Content-Type: application/json; 
charset=UTF-8 Server:
[
    {
        "label":"Spring '11",
        "url":"/services/data/v21.0",
        "version":"21.0"
    }
    ...
]
```

## Get a List of Resources

To retrieve a list of the resources available for Salesforce, in this example, for version 68.0, submit a [Resources by Version](https://developer.salesforce.com/docs/platform/api-rest/resources/resources-discoveryresource.md) request.

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/v68.0/ -H "Authorization: Bearer access_token"
```

The output from this request shows that `sobjects` is one of the available resources in Salesforce version 68.0.

```nolang
{
    "sobjects" : "/services/data/v68.0/sobjects",
    "search" : "/services/data/v68.0/search",
    "query" : "/services/data/v68.0/query",
    "recent" : "/services/data/v68.0/recent"
}
```

## Get a List of Available Objects

To request a list of the available objects, submit a [Describe Global](https://developer.salesforce.com/docs/platform/api-rest/resources/resources-describeglobal.md) request.

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/v68.0/sobjects/ -H "Authorization: Bearer access_token"
```

The output from this request shows that the Account object is available.

```nolang
Transfer-Encoding: chunked 
Content-Type: application/json; 
charset=UTF-8 Server:
{
 "encoding" : "UTF-8",
 "maxBatchSize" : 200,
 "sobjects" : [ {
    "name" : "Account",
    "label" : "Account",
    "custom" : false,
    "keyPrefix" : "001",
    "updateable" : true,
    "searchable" : true,
    "labelPlural" : "Accounts",
    "layoutable" : true,
    "activateable" : false,
    "urls" : { "sobject" : "/services/data/v68.0/sobjects/Account",
    "describe" : "/services/data/v68.0/sobjects/Account/describe",
    "rowTemplate" : "/services/data/v68.0/sobjects/Account/{ID}" },
    "createable" : true,
    "customSetting" : false,
    "deletable" : true,
    "deprecatedAndHidden" : false,
    "feedEnabled" : false,
    "mergeable" : true,
    "queryable" : true,
    "replicateable" : true,
    "retrieveable" : true,
    "undeletable" : true,
    "triggerable" : true },
   },
... 
```

## Get Basic Object Information

To retrieve basic information about the available Account object’s metadata, submit a [sObject Basic Information](https://developer.salesforce.com/docs/platform/api-rest/resources/resources-sobject-basic-info.md) request.

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/v68.0/sobjects/Account/ -H "Authorization: Bearer access_token"
```

The output from this request shows basic attributes of the Account object such as its name and label, and it lists the most recently used accounts.

```nolang
{
    "objectDescribe" : 
    {  
        "name" : "Account",  
        "updateable" : true,  
        "label" : "Account",  
        "keyPrefix" : "001",  
        
        ...
        
        "replicateable" : true,  
        "retrieveable" : true,  
        "undeletable" : true,  
        "triggerable" : true
    },
    "recentItems" : 
    [ 
        {  
            "attributes" : 
            {    
                "type" : "Account",    
                "url" : "/services/data/v68.0/sobjects/Account/001D000000INjVeIAL"  
            },  
            "Id" : "001D000000INjVeIAL",  
            "Name" : "asdasdasd"
        }, 

        ...

    ]
}
```

## Get a List of Fields

To retrieve more detailed information, submit a [sObject Describe](https://developer.salesforce.com/docs/platform/api-rest/resources/resources-sobject-describe.md) request.

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/v68.0/sobjects/Account/describe/ -H "Authorization: Bearer access_token"
```

The output from this request shows more detailed information about the Account object, such as its field attributes and child relationships.

```nolang
{
    "name" : "Account",
    "fields" : 
    [
        {
            "length" : 18,
            "name" : "Id",
            "type" : "id",
            "defaultValue" : { "value" : null },
            "updateable" : false,
            "label" : "Account ID",
            ...
        },
        ...
    ],
    "updateable" : true,
    "label" : "Account",
    ...
    "urls" : 
    {  
        "uiEditTemplate" : "https://MyDomainName.my.salesforce.com/{ID}/e",  
        "sobject" : "/services/data/v68.0/sobjects/Account",  
        "uiDetailTemplate" : "https://MyDomainName.my.salesforce.com/{ID}",  
        "describe" : "/services/data/v68.0/sobjects/Account/describe",  
        "rowTemplate" : "/services/data/v68.0/sobjects/Account/{ID}",  
        "uiNewRecord" : "https://MyDomainName.my.salesforce.com/001/e"
    },
    "childRelationships" : 
    [ 
        {  
            "field" : "ParentId",  
            "deprecatedAndHidden" : false,  
            ...
        }, 
        ...
    ],
     
    "createable" : true,
    "customSetting" : false,
    ...
}

```

## Execute a SOQL Query

To execute a SOQL query that retrieves a list of all the Account name values, submit a [Query](https://developer.salesforce.com/docs/platform/api-rest/resources/resources-query.md) request.

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/v68.0/query?q=SELECT+name+from+Account -H "Authorization: Bearer access_token"
```

The output lists the available Account names, and each name’s preceding attributes include the Account IDs.

```nolang
{
    "done" : true,
    "totalSize" : 14,
    "records" :
    [
        {
            "attributes" :
            {
                "type" : "Account",
                "url" : "/services/data/v68.0/sobjects/Account/001D000000IRFmaIAH"
            },
            "Name" : "Test 1"
        },
        {
            "attributes" :
            {
                "type" : "Account",
                "url" : "/services/data/v68.0/sobjects/Account/001D000000IomazIAB"
            },
            "Name" : "Test 2"
        },
        ...
    ]
}
```

**note:** You can find more information about SOQL in the [Salesforce SOQL and SOSL Reference Guide](https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/).

## Update a Field on a Record

To retrieve one of the accounts and update its billing city, submit an [sObject Rows](https://developer.salesforce.com/docs/platform/api-rest/resources/resources-sobject-retrieve.md) request. To update the object, create a text file called patchaccount.json containing the new billing city information.

```nolang
{
    "BillingCity" : "Fremont"
}
```

Specify this JSON file in the REST request. The cURL notation requires the `—d` option when specifying data. For more information, see [http://curl.haxx.se/docs/manpage.html](http://curl.haxx.se/docs/manpage.html).

Also, specify the `PATCH` method, which is used to update a REST resource. This cURL command retrieves the specified Account object using its ID field and updates its billing city.

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/v68.0/sobjects/Account/001D000000IroHJ -H "Authorization: Bearer access_token" -H "Content-Type: application/json" --data-binary @patchaccount.json -X PATCH
```

No response body is returned, just the headers.

```nolang
HTTP/1.1 204 No Content
Server: 
Content-Length: 0

```

To see that the billing address has changed to Fremont, refresh the page on the account.

