Update SQL draft version¶
Modifying the SQL content saved in the draft version will not execute the SQL. This interface cannot modify the finalized version.
POST $CLOUDSIGMA_API_BASE/workbook/version/update
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region.
Prepare personal access token and target workspace ID that can access the target workspace. The token must have updated version permissions.
Query the SQL workbook list, select and record the workbook ID.
Query the SQL workbook version list, select the version with the status of draft (
draft), and record the version ID.
Request body¶
Replace $CLOUDSIGMA_API_KEY, $WORKSPACE_ID, $WORKBOOK_ID, $VERSION_ID in the example with actual values.
curl -X POST "$CLOUDSIGMA_API_BASE/workbook/version/update" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{
\"workbook_id\": \"$WORKBOOK_ID\",
\"version_id\": \"$VERSION_ID\",
\"sql_content\": \"SELECT 1\"
}"
This interface completely replaces the SQL text. If omitted, null or an empty string is written as an empty string, the old SQL will be cleared. The finalized interface uses different rules: omit or null keep the old value.
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
The ID of the SQL workbook. |
|
string |
Yes |
Version ID in SQL workbook with status |
|
string |
No |
Complete replacement of SQL text, omission, null or empty string will clear the old value. |
Successful response¶
{
"code": 200,
"data": null
}
Field |
Type |
Description |
|---|---|---|
code |
integer |
200 on success. |
data |
null |
Fixed to null when update is successful. |
Error response¶
{
"code": 404,
"message": "SQL 工作簿或版本不存在"
}
Field |
Type |
Description |
|---|---|---|
|
integer or string |
Error code or status code. |
|
string |
error message. |
Common HTTP errors¶
HTTP status |
Error code |
Common cause |
Recommended action |
|---|---|---|---|
400 |
|
Invalid request field, workspace, or operation precondition. |
Fix the request parameters and submit again. |
401 |
|
Missing or invalid authentication credentials. |
Check the credential type, expiration, and authentication header. |
403 |
|
The current identity or active role does not have permission for this operation. |
Use an authorized identity or contact an administrator to grant access. |
404 |
|
The target object or required reference was not found. |
Verify the object identifier, workspace, and current status. |
409 |
|
Conflict in resource state, request payload, or concurrent modification. |
Re-read the current state and version, then handle according to the latest result. |
500 |
|
Internal processing failed; write operations may have been partially applied. |
Retain request and trace details, and verify the current state before retrying. |
503 |
|
A business, runtime, or authorization dependency is temporarily unavailable. |
After the dependency recovers, check existing results first instead of blindly repeating writes. |