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. Read Records

Read Single Record

PreviousRead RecordsNextRead List Records

Last updated 1 year ago

Record data is accessible via the , which takes a single record id and optionally a list of fields to fetch. By default, it will fetch all the fields the current user can read, which tends to be a huge amount.

GET /restapi/1.0/object/{object_name}/{id}

Request:

GET /restapi/1.0/object/res.partner/12 HTTP/1.1
Host: {your_Odoo_server_url}

JSON Response:

HTTP/1.1 200 OK

{
  'Partner': {
      'id': 12,
      'name': 'Think Big Systems',
      'street': '89 Lingfield Tower',
      'street2': false,
      'city': 'London',
      'state_id': false,
      'zip': false,
      'country_id': [486, 'United Kingdom'],
      'create_date': '2017-07-10 11:02:57',
      'create_uid': [1, 'Administrator'],
      'write_date': '2017-07-11 15:08:45',
      'write_uid': [1, 'Administrator'],
      ...
      ...
      ...
  }
}

XML Response:

HTTP/1.1 200 OK

<res.partner type="dict">
	<id type="int">12</id>
	<name type="str">Think Big Systems</name>
	<street type="str">89 Lingfield Tower</street>
	<street2 type="bool">false</street2>
	<city type="str">London</city>
	<state_id type="bool">false</state_id>
	<zip type="bool">false</zip>
	<country_id type="list">
		<item type="int">486</item>
		<item type="str">United Kingdom</item>
	</country_id>
	<create_date type="str">2017-07-10 11:02:57</create_date>
	<create_uid type="list">
		<item type="int">1</item>
		<item type="str">Administrator</item>
	</create_uid>
	<write_date type="str">2017-07-10 15:02:57</write_date>
	<write_uid type="list">
		<item type="int">1</item>
		<item type="str">Administrator</item>
	</write_uid>
</res.partner>

Query Parameters:

  • fields – OPTIONAL. list of field names to return (default is all fields).

Headers and Status Codes
Description

Request Headers

Response Headers

Status Codes

Conversely, picking only three fields deemed interesting.

Request:

GET /restapi/1.0/object/res.partner/12?fields=['name','country_id'] HTTP/1.1
Host: {your_Odoo_server_url}

JSON Response:

HTTP/1.1 200 OK

{
  'Partner': {
      'id': 12,
      'name': 'Think Big Systems',
      'country_id': [486, 'United Kingdom']
  }
}

Note

even if the id field is not requested, it is always returned

– 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

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