-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Hi,
I am having issues using the package right from the beginning.
When I do the simplest test, I get an error :
# testing melodi's get_catalog method > melodi::get_catalog() Request all catalog : https://api.insee.fr/melodi/catalog/all Error in `httr2::resp_body_json()`: ! Unexpected content type "text/html". • Expecting type "application/json" or suffix "json".
so I backtrace it, and get :
> rlang::last_trace() <error/rlang_error> Error in `httr2::resp_body_json()`: ! Unexpected content type "text/html". • Expecting type "application/json" or suffix "json". --- Backtrace: ▆ 1. └─melodi::get_catalog() 2. └─httr2::resp_body_json(httr2::req_perform(httr2::request(url)), simplifyVector = TRUE)
This shows the package is using httr2::resp_body_json to something of type text/html. And indeed :
# testing url content type > httr2::resp_content_type(httr2::req_perform(httr2::request("https://api.insee.fr/catalog/all"))) [1] "text/html"
It would be greatly appreciated to put some tests in this package so this does not happen on futur commits :)
Also, a quick fix would be great; probably have the package read the html, parse the content and translate it to json; but that being tried with :
# testing parsing xml to json so I can later parse the json > jsonlite::toJSON( xml2::read_xml( httr2::resp_body_string( httr2::req_perform( httr2::request("https://api.insee.fr/melodi/catalog/all") ) ) ), auto_unbox = TRUE, pretty = TRUE )
I get the error:
Erreur dans read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html, : Opening and ending tag mismatch: link line 12 and head [76] 5. read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html, options = options) 4. read_xml.character(httr2::resp_body_string(httr2::req_perform(httr2::request("https://api.insee.fr/melodi/catalog/all")))) 3. xml2::read_xml(httr2::resp_body_string(httr2::req_perform(httr2::request("https://api.insee.fr/melodi/catalog/all")))) 2. force(x) 1. jsonlite::toJSON(xml2::read_xml(httr2::resp_body_string(httr2::req_perform(httr2::request("https://api.insee.fr/melodi/catalog/all")))), auto_unbox = TRUE, pretty = TRUE)
which means something's off with the xml.
Maybe the xml should have some style information as seen from this screenshot
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels