# Update Single Record

A record can be updated using [write()](https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html#odoo.models.Model.write), it takes a record id to update and a mapping of updated fields to values similar to [create()](https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html#odoo.models.Model.create).

**`PUT /restapi/1.0/object/{object_name}/{id}?vals={fields_and_values_to_update}`**

**Request:**

```
PUT /restapi/1.0/object/res.partner/20?vals={'street2':'Chung Hsiao East Road'} HTTP/1.1
Host: {your_Odoo_server_url}
```

**JSON Response:**

```
HTTP/1.1 200 OK

{
  'Partner': {
      'id': 20,
      'name': 'Peter Mitchell',
      'street': '31 Hong Kong street',
      'street2': 'Chung Hsiao East Road',
      'city': 'Taipei',
      'state_id': false,
      'zip': '106',
      'country_id': [482, 'Taiwan'],
      'create_date': '2017-07-12 13:34:22',
      'create_uid': [1, 'Administrator'],
      'write_date': '2017-07-13 11:18:28',
      'write_uid': [1, 'Administrator'],
      ...
      ...
      ...
  }
}
```

**XML Response:**

```
HTTP/1.1 200 OK

<res.partner type="dict">
	<id type="int">20</id>
	<name type="str">Peter Mitchell</name>
	<street type="str">31 Hong Kong street</street>
	<street2 type="str">Chung Hsiao East Road</street2>
	<city type="str">Taipei</city>
	<state_id type="bool">false</state_id>
	<zip type="str">106</zip>
	<country_id type="list">
		<item type="int">482</item>
		<item type="str">Taiwan</item>
	</country_id>
	<create_date type="str">2017-07-12 13:34:22</create_date>
	<create_uid type="list">
		<item type="int">1</item>
		<item type="str">Administrator</item>
	</create_uid>
	<write_date type="str">2017-07-12 13:34:22</write_date>
	<write_uid type="list">
		<item type="int">1</item>
		<item type="str">Administrator</item>
	</write_uid>
</res.partner>
```

**Query Parameters:**

* **vals** –

  fields to update and the value to set on them:: <mark style="color:orange;">`{'field_name': field_value, ...}`</mark> see [write()](https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html#odoo.models.Model.write) for details.

| Headers and Status Codes | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Request Headers          | <ul><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-accept">Accept</a> – the response content type depends on <em>Accept</em> header</li><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-authorization">Authorization</a> – The OAuth protocol parameters to authenticate.</li></ul>                                                                                                                                                                            |
| Response Headers         | <ul><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-content-type">Content-Type</a> – this depends on <em>Accept</em> header of the request</li></ul>                                                                                                                                                                                                                                                                                                                          |
| Status Codes             | <ul><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok">200 OK</a> – no error</li><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found">404 Not Found</a> – there’s no resource</li><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-401-unauthorized">401 Unauthorized</a> – authentication failed</li><li><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-403-forbidden">403 Forbidden</a> – if any error raise</li></ul> |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://synconics.gitbook.io/rest-api/calling-methods/update-records/update-single-record.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
