Skip to content

Document how to handle non-hal+json responses - #320

Merged
dblock merged 1 commit into
codegram:masterfrom
dblock:dblock/doc-non-hal-json-responses
Aug 26, 2026
Merged

Document how to handle non-hal+json responses#320
dblock merged 1 commit into
codegram:masterfrom
dblock:dblock/doc-non-hal-json-responses

Conversation

@dblock

@dblock dblock commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Addresses #134.

By default, Hyperclient requires responses to have a Content-Type of application/hal+json, raising Hyperclient::InvalidRepresentationError otherwise. This came up in #134, where an API returned a 201 Created with an empty body and no matching content type on a _post.

The reporter confirmed a working workaround using a custom Faraday connection with a broadened content_type matcher:

client.connection do |conn|
  conn.request :json
  conn.response :json, content_type: /\bjson$/
end

This documents that workaround right next to the existing (very similar) default: false custom connection example in the README, so it's discoverable without having to dig through issues.

Checklist

  • I have added an entry to the changelog.

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@coveralls

coveralls commented Aug 26, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — dblock:dblock/doc-non-hal-json-responses into codegram:master

Addresses codegram#134: by default, Hyperclient requires a Content-Type of
application/hal+json and raises InvalidRepresentationError otherwise.
This documents the existing workaround (broadening the response
middleware's content_type matcher to /\bjson$/ via a custom
connection block with default: false), confirmed working by the
issue reporter.
@dblock
dblock force-pushed the dblock/doc-non-hal-json-responses branch from 4ba2743 to f2c2964 Compare August 26, 2026 21:45
@dblock
dblock merged commit 04522e1 into codegram:master Aug 26, 2026
10 checks passed
@dblock
dblock deleted the dblock/doc-non-hal-json-responses branch August 26, 2026 21:48
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