---
schema_version: "1"
id: 203ee21e1d470ac30830207f4221f9e2f990c50e36afc1d633051cf92a5521d0
title: Update a Record
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/api-rest/guides/do-me/dome-update-fields.md
canonical_url: https://developer.salesforce.com/docs/platform/api-rest/guide/dome-update-fields.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 75ba91f6ed7e88aca34ff44e3f3bc606cfc812747e87bdf318f2a243aa8db039
products:
  - REST API Developer Guide
  - Platform Developer Content
---

# Update a Record

You use the sObject Rows resource to update records. Provide the updated record information in your request data and use the PATCH method of the resource with a specific record ID to update that record. Records in a single file must be of the same object type.

In the following example, the Billing City within an Account is updated. The updated record information is provided in patchaccount.json.

## Example for updating an Account object

```nolang
curl https://MyDomainName.my.salesforce.com/services/data/v68.0/sobjects/Account/001D000000INjVe -H "Authorization: Bearer token" -H "Content-Type: application/json" -d @patchaccount.json -X PATCH
```

## Example request body patchaccount.json file for updating fields in an Account object

```nolang
{
    "BillingCity" : "San Francisco"
}
```

## Example response body for updating fields in an Account object

none returned

## Error response

See [Status Codes and Error Responses](https://developer.salesforce.com/docs/platform/api-rest/resources/errorcodes.md).

The following example uses Java and HttpClient to update a record using REST API. Note that there is no PatchMethod in HttpClient, so PostMethod is overridden to return “PATCH” as its method name. This example assumes the resource URL has been passed in and contains the object name and record ID.

<!-- otherprops: set_clipboard -->
```java
public static void patch(String url, String sid) throws IOException {
  PostMethod m = new PostMethod(url) {
    @Override public String getName() { return "PATCH"; }
  };

  m.setRequestHeader("Authorization", "OAuth " + sid);

  Map<String, Object> accUpdate = new HashMap<String, Object>();
  accUpdate.put("Name", "Patch test");
  ObjectMapper mapper = new ObjectMapper();
  m.setRequestEntity(new StringRequestEntity(mapper.writeValueAsString(accUpdate), "application/json", "UTF-8"));

  HttpClient c = new HttpClient();
  int sc = c.executeMethod(m);
  System.out.println("PATCH call returned a status code of " + sc);
  if (sc > 299) {
    // deserialize the returned error message
    List<ApiError> errors = mapper.readValue(m.getResponseBodyAsStream(), new TypeReference<List<ApiError>>() {} );
    for (ApiError e : errors)
      System.out.println(e.errorCode + " " + e.message);
  }
}

private static class ApiError {
  public String errorCode;
  public String message;
  public String [] fields;
}
```

If you use an HTTP library that doesn't allow overriding or setting an arbitrary HTTP method name, you can send a POST request and provide an override to the HTTP method via the query string parameter `_HttpMethod`. In the PATCH example, you can replace the PostMethod line with one that doesn't use override:

```java
PostMethod m = new PostMethod(url + "?_HttpMethod=PATCH");
```

**See Also**  


-   [sObject Rows](https://developer.salesforce.com/docs/platform/api-rest/resources/resources-sobject-retrieve.md)
-   [Conditional Request Headers](https://developer.salesforce.com/docs/platform/api-rest/intro/intro-rest-conditional-requests.md)

