Open
Conversation
Because some of them are CSV (e.g. reports), which raises a `JSON::ParserError` when trying to parse their body as JSON. This commit proposes an alternative way of enforcing usage of `JsonStruct`: overriding the method that parses JSON (`HTTParty::Parser#json`) rather than overriding the method that parses all formats (`HTTParty::Parser#parse`) and assume we always receive JSON.
This commit does 2 things when an UTF8 BOM is present in the response (even when HTTParty detects another encoding): 1. remove the BOM 2. force encoding of the body
Author
|
Just as a side note, I'm not sure how CSV data could be parsed automatically (with But if anyone has a good idea (better than checking the extension of the filename 😉), I'd be happy to implement it. |
Author
|
@kklimuk Is there anything I can add to help push this PR forward? |
This allows using `version: "beta"` 🚧
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.
This PR fixes 2 issues (thus 2 separate commits) I had with endpoints that return CSV responses (such as reports).
CSV are still not automatically parsed (because HTTParty does not detect they are CSV since the API doesn't seem to provide the appropriate
Content-Typeheaders 🙄), but at least they do not raise an error anymore 😅