Send Submit an Inspection's rewritten body as JSON - #61
Open
roncodes wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"Submit an Inspection" has failed every contract run since postman#60 merged. Its body arrived at the API empty.
The request's pre-request script rebuilds the body to add
custom_field_values, which name fields by the ids "Retrieve an Inspection Form" read.pm.request.body.update({ mode: "raw", raw: ... })replaces the body wholesale, including the rawjsonlanguage, so the rebuilt body went out astext/plain. Laravel parsed none of it and refused every field as missing:In the contract run's output it was the only one of 120 write requests sent as
↑ text; the other 117 went as↑ json. Before fleetbase/fleetops#319 made inspection routes answer in JSON, the same refusal came back as a redirect, which the runner followed to a port nothing listens on and reported asECONNREFUSED. "Retrieve an Inspection" then 404s because nothing was filed.Change
pm.request.body.update({ mode: "raw", raw, options: { raw: { language: "json" } } }).Content-Type: application/jsonexplicitly, so the header doesn't depend on the language being carried over.Accept: application/json, so a refusal is always a readable 422.No other request in the collection rewrites its body this way.
Related Issue
Follows #60. Unblocks the Postman contract check on fleetbase/fleetops#319, which runs the collection at
postman-ref: main.Type of Change
Validation
scripts/validate-collections.jsandpostman collection lintpass, and the pre-request script passesnode --check. Against a local FleetOps test harness, the same payload sent as JSON files the inspection: all three field values are stored, and the photo and the signature come back as files with URLs, which is what the request's assertions check. It has not been run against the CI stack; the next contract run on fleetops#319 after this merges will do that.Risk
Low. One request's pre-request script and headers.