Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle non-hal+json responses #134

Open
espen opened this issue Jan 31, 2018 · 3 comments
Open

Handle non-hal+json responses #134

espen opened this issue Jan 31, 2018 · 3 comments
Labels

Comments

@espen
Copy link

espen commented Jan 31, 2018

Responses are currently required to be hal+json. The API we consume returns a 201 without data and a http header for a new location when we do a _post. The request is successful but Hyperclient gives a InvalidRepresentationError due to the response not being hal+json.

This works in v0.8.5 but not in the latest version due to 1c7dc4c

I'll provide a failing test later.

@dblock dblock added the bug? label Jan 31, 2018
@dblock
Copy link
Collaborator

dblock commented Jan 31, 2018

You should be able to add the right headers or do something like

    conn.request :json
    conn.response :json, content_type: /\bjson$/

If the README is not clear appreciate some PRs.

@espen
Copy link
Author

espen commented Jan 31, 2018

Thanks, overriding response content type works. I assumed the problem was due to the empty body.

client.connection do |conn|
  conn.response :hal_json
end

This is the first hal-json API I'm using so not sure what the norm is. If it is normal to retrieve a response like this with empty body and without content-type then perhaps this user case should be more explicit in the readme (I can provide a PR for that). If this is some uncommon scenario then no worries.

@dblock
Copy link
Collaborator

dblock commented Jan 31, 2018

Please PR anything! Documentation never hurt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants