Can you share the code where you get this?
Can you share the code where you get this?

CREATE TABLE IF NOT EXISTS "test_table" ("val1" INTEGER); beforehand. Could you provide a repo with a minimal reproduction?Failed to parse body as JSON, got: error code: 1042—remote mode in wranglerasync function InsertIntoContentDatabase(db:D1Database, content:ContentDataType): Promise<D1Result<unknown>[]>{
try {
if(content.contentDataItemType === undefined){
console.log('No contentDataItemType');
throw('Missing contentDataItemType Array');
}
//Because we may have multiple items to push into the database, we need to batch the call
const batcher = await db.prepare("INSERT INTO content_models (contentGroupRef, projectRef, contentElementRef, contentBakedStatement, publishState) VALUES (?1, ?2, ?3, ?4, ?5)")
let binderCollection=[];
for (let index = 0; index < content.contentDataItemType.length; index++) {
const element = content.contentDataItemType[index];
let temp = batcher.bind(
element.contentGroupRef,
element.projectRef,
element.contentElementRef,
element.contentBakedStatement,
element.publishState
);
binderCollection.push(temp);
console.log('Loop Batch=>', JSON.stringify(temp));
}
return await db.batch(binderCollection);
} catch (error:any) {
console.log('D1 Instance=>', JSON.stringify(db.dump()));
console.log({
message: error.message,
cause: error.cause.message,
});
throw(error);
}
}Loop Batch=> {"database":{"fetcher":{}},"statement":"UPDATE content_models SET contentGroupRef = ?2, projectRef = ?3, contentBakedStatement = ?4, publishState = ?5 WHERE contentElementRef = ?1","params":["ref0","cg0","prTest0","We are proud to present a gorgeous large green wall panel square made from ivory wood.",1]}Loop Batch=> {"database":{"fetcher":{}},"statement":"INSERT INTO content_models (contentGroupRef, projectRef, contentElementRef, contentBakedStatement, publishState) VALUES (?1, ?2, ?3, ?4, ?5)","params":["cg0","prTest0","ref0","We are proud to present a gorgeous large green wall panel square made from ivory wood.",1]}Error=> Error: D1_ERROR: Failed to parse body as JSON, got: error code: 1042
at D1Database._send (cloudflare-internal:d1-api:105:19)
at async D1Database.exec (cloudflare-internal:d1-api:41:23)
at async InsertIntoContentDatabase (file:///C:XXXXX/Temp/tmp-35236-4jsc2tuBSi4U/index.js:3232:5)
at async RunContent (file:///C:XXXXX/Temp/tmp-35236-4jsc2tuBSi4U/index.js:3155:17)
at async Array.<anonymous> (file:///C:XXXXX/Temp/tmp-35236-4jsc2tuBSi4U/index.js:3727:12)
at async file:///C:XXXXX/Temp/tmp-35236-4jsc2tuBSi4U/index.js:2408:21 {
stack: Error: D1_ERROR: Failed to parse body as JSON, got…ocal/Temp/tmp-35236-4jsc2tuBSi4U/index.js:2408:21,
message: D1_ERROR: Failed to parse body as JSON, got: error code: 1042,
cause: Error: Failed to parse body as JSON, got: error code: 1042
at D1Database._send (cloudflare-inte…
}Object {
message: D1_EXEC_ERROR: Error in line 1: INSERT INTO conten…'test1','test1',1): no such table: content_models,
cause: Error in line 1: INSERT INTO content_models (conte…'test1','test1',1): no such table: content_models
}Object {
message: D1_ERROR: Failed to parse body as JSON, got: error code: 1042,
cause: Failed to parse body as JSON, got: error code: 1042
}return await db.exec("INSERT INTO test_table (val1) VALUES (1)");export interface Env {
DB: D1Database;
}
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext
): Promise<Response> {
const res = await env.DB.exec("INSERT INTO test_table (val1) VALUES (1)");
console.log("res: ", res);
return new Response("Hello World!");
},
};CREATE TABLE IF NOT EXISTS "test_table" ("val1" INTEGER);Failed to parse body as JSON, got: error code: 1042—remote