Skip to content

fix(api): default request body to application/vnd.api+json - #160

Merged
shadowhand merged 1 commit into
mainfrom
feature/cl-10-rw-api-forces-content-type-applicationjson-and-ignores-h
Oct 26, 2026
Merged

shadowhand merged 1 commit into
mainfrom
feature/cl-10-rw-api-forces-content-type-applicationjson-and-ignores-h

Conversation

@shadowhand

@shadowhand shadowhand commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

rw api -f ... now defaults JSON bodies to Content-Type: application/vnd.api+json. It used to send application/json, which RoundingWell API rejected.

A Content-Type passed with -H still wins, matched case-insensitively. Pass -H "Content-Type: application/json" to get the old behavior.

Accept stays at reqwest's */*, which already accepts JSON:API responses. A strict application/vnd.api+json default could break endpoints that return other media types. Callers can still pass -H "Accept: ...".

Changes

  • In src/commands/api.rs, the -f body defaults to application/vnd.api+json unless -H sets Content-Type.
  • New mockito tests call run() and check the Content-Type and body the server receives. They cover -f with no -H, -H "Content-Type: application/json", a mixed-case header name, and an unrelated -H Accept.
  • The --field help text in src/cli.rs names the default media type.
  • The README notes the default and shows the --header "Content-Type: application/json" override.

Closes CL-10

Verification

  • cargo fmt --check and cargo clippy --all-targets --all-features -- -D warnings are clean.
  • cargo test --locked passes, and cargo audit reports no vulnerabilities.
  • Against a local echo server (--stage local), -X PUT -f data.type=jobs sent application/vnd.api+json, and adding -H "content-type: application/json" sent application/json.

rw api -f bodies now default to Content-Type: application/vnd.api+json, which JSON:API routes require. A Content-Type passed with -H still wins, matched case-insensitively.
@shadowhand
shadowhand force-pushed the feature/cl-10-rw-api-forces-content-type-applicationjson-and-ignores-h branch from e94b8c7 to 1effbef Compare October 26, 2026 20:30
@shadowhand shadowhand changed the title test(api): cover caller Content-Type with -f fields fix(api): default request body to application/vnd.api+json Oct 26, 2026
@shadowhand
shadowhand requested a review from wweaver4th October 26, 2026 20:49
@shadowhand
shadowhand merged commit 4a9bd84 into main Oct 26, 2026
6 checks passed
@shadowhand
shadowhand deleted the feature/cl-10-rw-api-forces-content-type-applicationjson-and-ignores-h branch October 26, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants