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

Explicitly use as="text" when using httr::content #1

Merged
merged 1 commit into from
Aug 23, 2020
Merged

Explicitly use as="text" when using httr::content #1

merged 1 commit into from
Aug 23, 2020

Conversation

fjukstad
Copy link
Contributor

First off, thanks for the great package!

I had some issues using it, getting the error

Error: Argument 'txt' must be a JSON string, URL or file.

when using any of the get-methods. I did some debugging and figured out that it was because httr::content automatically parsed the JSON response from the withings API, so subsequent calls to jsonlite::fromJSON(out) failed because out was
already an object.

Anyways, I've added the option to explicitly use text when reading the content from the response. This fixed the issue for me.

Cheers,
Bjørn

`httr::content` automatically parsed the JSON response from the withings
API, so calling `jsonlite::fromJSON(out)` failed because `out` was
already an object. This change enforces `httr::content` to read the
content as a text string so we can use `fromJSON` to parse the json.
@fjukstad fjukstad changed the title explicitly use "text" for the HTTP GET response Explicitly use as="text" when using httr::content Aug 22, 2020
@mathesong
Copy link
Owner

Hey!

Thanks so much for getting in touch, and thanks for already figuring out the issue!

I see that I get the same error now on my old code that used to work, and it's all resolved by your PR on my machine too. I guess it must have to do with the latest updates to httr.

This is really awesome! I'll just merge directly! Thanks again!!

All the best,
Granville

@mathesong mathesong merged commit 2cfdaa9 into mathesong:master Aug 23, 2020
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.

None yet

2 participants