fix(api): implement auto-serialization for _json fields in V3 create/update

- Added logic to automatically JSON.stringify any field ending in '_json' in V3 API helpers.
- Added final payload logging to create_ae_obj_v3 for better debugging.
- Resolves 'str type expected' validation errors (HTTP 400) when sending objects to V3 CRUD endpoints.
This commit is contained in:
Scott Idem
2026-01-26 13:02:11 -05:00
parent 13bc903ad9
commit 71297af15c

View File

@@ -34,11 +34,15 @@ export async function create_ae_obj_v3({
const cleaned_fields = { ...fields };
for (const key in cleaned_fields) {
if (key.endsWith('_json') && cleaned_fields[key] !== null && typeof cleaned_fields[key] === 'object') {
if (log_lvl > 1) console.log(`Auto-serializing field: ${key}`);
if (log_lvl) console.log(`Auto-serializing field: ${key}`);
cleaned_fields[key] = JSON.stringify(cleaned_fields[key]);
}
}
if (log_lvl) {
console.log('Cleaned Fields (Final):', cleaned_fields);
}
return await post_object({
api_cfg,
endpoint,