Skip to main content

Get record by ID

The "getRecordsById" action is the best way to retrieve records using primary keys and foreign keys. It uses the id property to return one or more records from a table. The JSON DB API always creates a table with the id property, but some other APIs may not. For tables created without an "id" property, the "getRecordsById" action allows you to use the table’s primary key to retrieve records.

This procedure returns two records from the "athlete" table with "id" values of 1 and 3.

  1. Paste this code into the API Request editor.

    {
        "api": "db",
        "action": "getRecordsByIds",
        "params": {
            "tableName": "athlete",
            "ids": [1,3]
        },
        "authToken": "clickApplyDefaultsToReplaceThisWithValidAuthToken"
    }
    
  2. Click Apply defaults to JSON request (Apply) to set the "authToken" to a valid value.

  3. Click Send request (Run Icon).

  4. Verify the action completed successfully.

    Note

    "errorCode" with a value of 0 indicates success. "errorCode" with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.