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

Error with non-unicode character in response from POST #693

Closed
glaroc opened this issue Jun 22, 2021 · 2 comments
Closed

Error with non-unicode character in response from POST #693

glaroc opened this issue Jun 22, 2021 · 2 comments

Comments

@glaroc
Copy link

glaroc commented Jun 22, 2021

I run httr::POST with the following to an API endpoint as JSON

{
    "vascan_id": 5484,
    "name": "Equisetum ×nelsonii",
    "vernacular_fr": "prêle de nelson",
    "vernacular_en": "nelson's scouring-rush",
    "rank": "espèce_hybride",
    "category": "plantes",
}

Note the "×" in the name value. This gets accepted properly to the API and inserted into our database. However, httr errors out on the response with

Error in substring(u, so, so + ml - 1L) : invalid multibyte string, element 1

It seems that it can deal with the non-unicode character for posting to the API, but not in the response. Note that the response is encoded in utf-8. Doing the same POST with Postman poses no issues. Are there any ways to prevent this error ?

@jjesusfilho
Copy link

I am getting the same response when using httr. When I use curl::curl_fetch_memory, it works:

url <- "https://ww2.stj.jus.br/websecstj/cgi/revista/REJ.cgi/ITA?seq=1975824&tipo=0&nreg=202001655224&SeqCgrmaSessao=&CodOrgaoJgdr=&dt=20200904&formato=PDF&salvar=false"
response <- httr::GET(url)
response <- curl::curl_fetch_memory(url)

@hadley
Copy link
Member

hadley commented Oct 31, 2023

httr has been superseded in favour of httr2, so is no longer under active development. If this problem is still important to you in httr2, I'd suggest filing an issue offer there 😄. Thanks for using httr!

@hadley hadley closed this as completed Oct 31, 2023
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

No branches or pull requests

3 participants