Error with non-unicode character in response from POST
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 ?
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)
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!