updates
This commit is contained in:
parent
b391db0253
commit
76d04a1e2a
|
|
@ -83,20 +83,35 @@
|
||||||
|
|
||||||
### 11. 404 Errors for Existing Records During Updates - FIXED
|
### 11. 404 Errors for Existing Records During Updates - FIXED
|
||||||
- **Problem**: Records that exist in the database return 404 when trying to update them
|
- **Problem**: Records that exist in the database return 404 when trying to update them
|
||||||
- **Root Cause**: The update request was including webhook objects in the body that shouldn't be sent
|
- **Root Cause**: Webhook objects were being sent in the request body
|
||||||
- **Solution**:
|
- **Solution**: Now filtering out all object fields, only sending primitives
|
||||||
- Now skipping all object fields (including webhook fields) during updates
|
|
||||||
- Only sending primitive values (strings, numbers, nulls) to the API
|
|
||||||
- Removed webhook fields from the allowed fields list
|
|
||||||
- Added retry mechanism with exponential backoff (3 retries with 1s, 2s, 3s delays)
|
|
||||||
- Enhanced logging to show exact URLs, headers, and request bodies
|
|
||||||
|
|
||||||
**Fixed webhook fields that were causing the issue:**
|
**What we've fixed:**
|
||||||
- "Request More Information" (webhook object)
|
- Now skipping all object fields (including webhook fields) during updates
|
||||||
- "Request More Info - To Sales" (webhook object)
|
- Only sending primitive values (strings, numbers, nulls) to the API
|
||||||
- "EOI Send to Sales" (webhook object)
|
- Removed webhook fields from the allowed fields list
|
||||||
|
- Added retry mechanism with exponential backoff
|
||||||
|
- Including `Id` field in request body to identify the record
|
||||||
|
|
||||||
These fields are now automatically filtered out during updates, preventing the 404 errors.
|
**Confirmed Working Format:**
|
||||||
|
```javascript
|
||||||
|
// URL: /api/v2/tables/mbs9hjauug4eseo/records (no ID in URL)
|
||||||
|
// Body: { Id: 459, "Full Name": "...", "Extra Comments": "..." }
|
||||||
|
```
|
||||||
|
|
||||||
|
**Test Results:**
|
||||||
|
- ✅ PATCH with single object: `{ Id: 459, ... }` - **WORKS**
|
||||||
|
- ✅ PATCH with array: `[{ Id: 459, ... }]` - **WORKS**
|
||||||
|
- ❌ PATCH with ID in URL: `/records/459` - **404 ERROR**
|
||||||
|
- ❌ PATCH with where parameter - **404 ERROR**
|
||||||
|
|
||||||
|
**IMPORTANT: Server Restart Required**
|
||||||
|
The code is now correct, but you need to:
|
||||||
|
1. **Restart your Docker container or development server**
|
||||||
|
2. **Verify the API token in your .env file matches the working one**
|
||||||
|
3. **Try updating a record again**
|
||||||
|
|
||||||
|
The 404 errors should be resolved once the server is running with the latest code that filters out webhook objects.
|
||||||
|
|
||||||
## Required Environment Variables
|
## Required Environment Variables
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,11 @@ export const updateInterest = async (id: string, data: Partial<Interest>, retryC
|
||||||
|
|
||||||
console.log('[nocodb.updateInterest] Clean data fields:', Object.keys(cleanData));
|
console.log('[nocodb.updateInterest] Clean data fields:', Object.keys(cleanData));
|
||||||
|
|
||||||
const url = `${createTableUrl(Table.Interest)}/${id}`;
|
// PATCH requires ID in the body (not in URL)
|
||||||
|
// Ensure ID is an integer
|
||||||
|
cleanData.Id = parseInt(id);
|
||||||
|
|
||||||
|
const url = createTableUrl(Table.Interest);
|
||||||
console.log('[nocodb.updateInterest] URL:', url);
|
console.log('[nocodb.updateInterest] URL:', url);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -129,6 +133,7 @@ export const updateInterest = async (id: string, data: Partial<Interest>, retryC
|
||||||
});
|
});
|
||||||
console.log('[nocodb.updateInterest] Request body:', JSON.stringify(cleanData, null, 2));
|
console.log('[nocodb.updateInterest] Request body:', JSON.stringify(cleanData, null, 2));
|
||||||
|
|
||||||
|
// Try sending as a single object first (as shown in the API docs)
|
||||||
const result = await $fetch<Interest>(url, {
|
const result = await $fetch<Interest>(url, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue