i have this piece of code
try:
# Step 1: Search for the record with the given unique ID
print("stage 1")
search_url = f'{url}?filterByFormula={{Part unique No 1}}="unique_id"'
print("stage 2")
search_response = requests.get(search_url, headers=headers)
print(search_response)
if search_response.status_code == 200:
search_result = search_response.json()
if search_result['records']:
# Step 2: If record is found, extract the record ID and existing quantity
record_id = search_result['records'][0]['id']
existing_fields = search_result['records'][0]['fields']
existing_quantity = existing_fields.get('Quantity', 0)
# Step 3: Add the new quantity to the existing quantity
updated_quantity = existing_quantity + int(new_quantity)
# Step 4: Prepare the data for the update
update_data = {
"fields": {
"Quantity": updated_quantity,
"keptBy": kept_by,
"location": location
}
}
# Step 5: Send the PATCH request to update the record
update_url = f'{url}/{record_id}'
update_response = requests.patch(update_url, json=update_data, headers=headers)
what it does is it searches my air-table base in a particular field("Part unique No 1") whether it matches with ("unique_id") if it matches it updates that particular row of that particular ("Part unique No 1")
but, the issue is it's not working the way it should be... what i think i'm using filter by formula in a wrong manner.
help by anyone would be appreciated..
thankyou in advance