From a801770897fdb1bed44d6feba3e35567f3ecbee1 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 11 Sep 2026 20:15:02 +0800 Subject: [PATCH] Send Submit an Inspection's rewritten body as JSON The pre-request script rebuilds the body to add custom_field_values, and pm.request.body.update() replaced it without its raw language. The body went out as text/plain, the API parsed none of it, and answered that every field was missing: a 422 once fleetops#319 answers inspection routes in JSON, and before that a redirect the runner reported as ECONNREFUSED. It was the only one of 120 write requests in the contract run sent as text. The rewrite now restates the JSON language and sets Content-Type, and the request asks for application/json. --- .../Inspections/Submit an Inspection.request.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/postman/collections/Fleetbase API/Inspections/Submit an Inspection.request.yaml b/postman/collections/Fleetbase API/Inspections/Submit an Inspection.request.yaml index ed1fa08..c83add9 100644 --- a/postman/collections/Fleetbase API/Inspections/Submit an Inspection.request.yaml +++ b/postman/collections/Fleetbase API/Inspections/Submit an Inspection.request.yaml @@ -18,6 +18,7 @@ url: "{{base_url}}/{{namespace}}/inspections" method: POST headers: Idempotency-Key: "{{$guid}}" + Accept: application/json body: type: json content: |- @@ -98,7 +99,11 @@ scripts: const body = JSON.parse(pm.request.body.raw); body.custom_field_values = values; - pm.request.body.update({ mode: "raw", raw: JSON.stringify(body, null, 2) }); + // update() replaces the body wholesale, including the raw language that + // made it JSON: without restating it the rewritten body went out as + // text/plain, the API parsed nothing, and refused every field as missing. + pm.request.body.update({ mode: "raw", raw: JSON.stringify(body, null, 2), options: { raw: { language: "json" } } }); + pm.request.headers.upsert({ key: "Content-Type", value: "application/json" }); pm.environment.set("inspection_submitted_field_values", String(values.length)); language: text/javascript