Update Data With Filter
- To update data in a worksheet with filter, you need the following 3 parameters:
- 1.Token
- 2.Worksheet Id
- 3.App Id
PUT
https://api.tablesprint.com/api/platform/worksheet/upsert/{appId}/{worksheetId}
URL Parametersβ
Parameter | Type | Required | Description |
---|---|---|---|
appId | string | Yes | The unique identifier of the application |
worksheetId | string | Yes | The unique identifier of the worksheet |
To get url parameters follow these steps:
- 1.Click on the downward arrow beside the worksheet name.
- 2.A dialog box with options will open.
- 3.Click on More Info, and you'll see the worksheetId and AppId.
Request Body Parametersβ
Parameter | Type | Required | Description |
---|---|---|---|
columnName | string | yes | The name of the column to be updated. |
value | string | yes | The new value to update the column with. |
- Filters allow you to update rows based on specific conditions rather than using the _id of each row. This is useful when you want to modify multiple rows that meet certain criteria.
The filter object contains the following properties:
- 1.condition: Defines the type of filter operation (e.g., "where" to specify a condition).
- 2.column: The name of the column to apply the filter on.
- 3.operator: Specifies the operator.
- How Filter operator works. Refer here
- 4.operand_1: The value that the column is compared against.
Filterβ
"data":
{
"columnName1": "Updated Value1",
"columnName2": "Updated Value2",
"columnName3": "Updated Value3",
},
"filter": {
"condition": "where",
"column": "text",
"operator": "=",
"operand_1": "Narayan"
},
"isUpsert": false
}
Upsertβ
-
Use the isUpsert parameter to update a record if it exists or create it if it doesnβt. Itβs optional and only takes effect when set to true.
-
When isUpsert is set to true, the operation follows these rules:
-
1.If a record matching the filter condition is found, it is updated with the new values.
-
2.If no matching records are found, a new record is inserted using the provided data.
{
"data":
{
"columnName1": "Update Value1",
"columnName2": "Update Value2",
"columnName3": "Update Value3"
},
"filter": {
"condition": "where",
"column": "salary",
"operator": "=",
"operand_1": "6666"
},
"isUpsert":true
}
Request Headers
Header | Value |
---|---|
Authorization | Bearer YOUR_ACCESS_TOKEN |
Content-Type | application/json |
Example Requestβ
Here's an example of how to make this request with filter:
curl -L -X PUT 'https://api.tablesprint.com/api/platform/worksheet/upsert/appId/worksheetid' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-d '{
"data":
{
"columnName1": "Updated Value1",
"columnName2": "Updated Value2",
},
"filter": {
"condition": "string",
"column": "string",
"operator": "string",
"operand_1": "string"
}
}'
Here's an example of how to make this request with isUpsert:
curl -L -X PUT 'https://api.tablesprint.com/api/platform/worksheet/upsert/077c6bd4-4c75-4919-92e5-7b584d361d30/96e741e3-44b6-4e26-98d9-ec63d84ec685' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyZXF1ZXN0SWQiOiJmY2JlNzVjYy02ODk4LTRhZGMtOGU1YS0yYzczYWFjYjZlM2UiLCJ1c2VyVHlwZSI6IlBBVCIsImlhdCI6MTc0NDE5MzE5MiwiZXhwIjoxNzQ2MDA3NTU5fQ.ckKXuMz1RZdirYltAzC2NizjszlL7Jv3zPG09oIdmXA' \
-d '{
"data":
{
"columnName1": "Updated Value1",
"columnName2": "Updated Value2",
},
"filter": {
"condition": "where",
"column": "text",
"operator": "=",
"operand_1": "Narayan"
},
"isUpsert": true
}'
Responseβ
A successful request returns the HTTP 200 OK
status code and JSON response body.
- results.updateCount : Represents the number of rows that were updated when upsert is set to true and a matching row already exists.
- results.insertCount : Represents the number of new rows added when no existing match is found and when upsert is set to true.
- In case you get other error codes: Refer here
{
"results": {
"updateCount": 0,
"insertCount": 2
},
"success": true
}
Response Headers
Header | Description |
---|---|
Content-Type | application/json |