Rest API
  • Odoo REST API: Version 1.0 documentation
  • Connection
    • Configuration
    • Demo
    • Logging In
      • How you can do
        • Odoo Version Information
        • Oauth1 Authentication
        • OAuth2 Authentication
        • Basic Authentication
  • Calling Methods
    • Check Access Rights
    • List Records
      • Pagination
    • Count Records
    • Read Records
      • Read Single Record
      • Read List Records
      • Read Filter Records
    • Listing Record Fields
    • Create Records
    • Update Records
      • Update Single Record
      • Update List Records
    • Delete Records
      • Delete Single Record
      • Delete List Records
  • Report Printing
    • Print Single Report
    • Print List Reports
  • Inspection and Introspection
    • ir.model
    • ir.model.fields
Powered by GitBook
On this page
  1. Calling Methods
  2. Update Records

Update Single Record

PreviousUpdate RecordsNextUpdate List Records

Last updated 1 year ago

A record can be updated using , it takes a record id to update and a mapping of updated fields to values similar to .

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 –

Headers and Status Codes
Description

Request Headers

Response Headers

Status Codes

fields to update and the value to set on them:: {'field_name': field_value, ...} see for details.

– the response content type depends on Accept header

– The OAuth protocol parameters to authenticate.

– this depends on Accept header of the request

– no error

– there’s no resource

– authentication failed

– if any error raise

write()
create()
write()
Accept
Authorization
Content-Type
200 OK
404 Not Found
401 Unauthorized
403 Forbidden