{"record":{"id":"e2626c49d8894fc4","repo":"louislam/uptime-kuma","slug":"your-json-body-is-invalid-e-message","errorCode":null,"errorMessage":"Your JSON body is invalid. ${e.message}","messagePattern":"Your JSON body is invalid\\. (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/model/monitor.js","lineNumber":546,"sourceCode":"\n                    const httpAgentOptions = {\n                        maxCachedSessions: 0,\n                        autoSelectFamily: true,\n                        ...(agentFamily ? { family: agentFamily } : {}),\n                    };\n\n                    log.debug(\"monitor\", `[${this.name}] Prepare Options for axios`);\n\n                    let contentType = null;\n                    let bodyValue = null;\n\n                    if (this.body && typeof this.body === \"string\" && this.body.trim().length > 0) {\n                        if (!this.httpBodyEncoding || this.httpBodyEncoding === \"json\") {\n                            try {\n                                bodyValue = JSON.parse(this.body);\n                                contentType = \"application/json\";\n                            } catch (e) {\n                                throw new Error(\"Your JSON body is invalid. \" + e.message);\n                            }\n                        } else if (this.httpBodyEncoding === \"form\") {\n                            bodyValue = this.body;\n                            contentType = \"application/x-www-form-urlencoded\";\n                        } else if (this.httpBodyEncoding === \"xml\") {\n                            bodyValue = this.body;\n                            contentType = \"text/xml; charset=utf-8\";\n                        }\n                    }\n\n                    // Axios Options\n                    const options = {\n                        url: this.url,\n                        method: (this.method || \"get\").toLowerCase(),\n                        timeout: this.timeout * 1000,\n                        headers: {\n                            Accept: \"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\",\n                            ...(contentType ? { \"Content-Type\": contentType } : {}),","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/model/monitor.js#L528-L564","documentation":"Thrown by an HTTP/HTTPS monitor when HTTP Body Encoding is 'json' (the default when unset) and the configured request body fails JSON.parse. Uptime Kuma parses this.body into a JS object so axios can send it as application/json; any JSON syntax error aborts the beat and marks it DOWN.","triggerScenarios":"Saving an HTTP monitor with a non-empty body while httpBodyEncoding is unset or 'json', and the body string is not valid JSON (trailing comma, single quotes, unescaped newline, comments, smart quotes).","commonSituations":"Pasting JSON copied from docs/chat that introduced curly quotes; copy-paste leaving a trailing comma; user intends form-urlencoded but left encoding on the default 'json'.","solutions":["Run JSON.parse on the body in a JS console before saving to locate the exact syntax error","If the body is not JSON, set HTTP Body Encoding to 'form' or 'xml' in the monitor settings","Escape embedded quotes and newlines inside string values","Re-type quotes manually instead of pasting to avoid smart/curly quotes"],"exampleFix":"// before\nthis.body = \"{'name': 'kuma',}\";\n\n// after\nthis.body = '{\"name\":\"kuma\"}';","handlingStrategy":"validation","validationCode":"// Pre-check a JSON body before saving the HTTP monitor\nfunction assertJsonBody(body, encoding) {\n  if (!body || (encoding && encoding !== \"json\")) return; // not in json mode\n  try {\n    JSON.parse(body);\n  } catch (e) {\n    throw new Error(`Body is not valid JSON: ${e.message}`);\n  }\n}","typeGuard":"// Confirm body parses to an object/array (json encoding only)\nfunction isValidJsonBody(body, encoding) {\n  if (!body || (encoding && encoding !== \"json\")) return true;\n  try {\n    const v = JSON.parse(body);\n    return typeof v === \"object\" && v !== null;\n  } catch {\n    return false;\n  }\n}","tryCatchPattern":null,"preventionTips":["Default to validating any JSON field with JSON.parse before saving the monitor","If the body is not JSON, switch HTTP Body Encoding away from the default 'json'"],"tags":["json","http","validation","monitor-config"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}