Search code examples
quickbase

Issues with Quickbase API call


I am using JSON Quickbase API documentation below:

Quickbase API

I am trying to update records with Quickbase via recordId as per below, and it's working fine:

{
  "to": "my-table-id-goes-here",
  "data": [
    {


      "6": {
        "value": "nancy more is the value to be updated"
      },

"3": {
        "value": "recordId_to_be_used_to_make_updates"
      }

    }
  ]
  
}

My issue: I want to update where email and userid is equal to certain value.

Eg. in normal SQL queries something like "update mytable_name set name ='nancy more' where email='[email protected]' and userid=70".

Is it possible with Quickbase? Is there a way to achieve that based on the code above, assuming email field is 7 and userid field is 8 or whatever?


Solution

  • The end result is possible but not through a single API call. The insert/update records API call for Quick Base only updates records when the key field is included in the record payload (the key field is the record ID by default but can be changed to another field in the table). If you don't already know the value of the key field, you'll need to query for the matching records first and then use the returned record ID/key field to perform that update.

    For example, you could query for records where email is "[email protected]" and userid is 70:

    POST https://api.quickbase.com/v1/records/query
    QB-Realm-Hostname: host
    Authorization: QB-USER-TOKEN userToken
    Content-Type: application/json
    
    {
        "from": "tableId",
        "where": "{7.EX.'[email protected]'}AND{8.EX.70}"
    }
    

    You can then use the id's of the returned set of records to perform your update. How you go about reading the response and making the upsert request will depend on the language you're using.