Hello,
I am trying to use the API provided by the Geocoding service to geocode addresses.
The use looks simple, according to the docs they are expecting url in this structure:
Forward Geocode: https://geocode.maps.co/search?q=address&api_key=api_key
My code is as follows:
address <- "Prince st., New York 10012"
api_key <- "my_secret_api_key"
url <- glue::glue("https://geocode.maps.co/search?q={address}&api_key={api_key}")
response <- httr2::request(url) %>%
httr2::req_perform()
However this does not work, I am getting this error message:
<error/httr2_failure>
Error in `httr2::req_perform()`:
! Failed to perform HTTP request.
Caused by error in `curl::curl_fetch_memory()`:
! URL rejected: Malformed input to a URL function
---
Backtrace:
▆
1. ├─httr2::request(url) %>% httr2::req_perform()
2. └─httr2::req_perform(.)
3. └─base::tryCatch(...)
4. └─base (local) tryCatchList(expr, classes, parentenv, handlers)
5. └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
6. └─value[[3L]](cond)
I tried also the older package httr, it did not work too :
httr::GET(url)
What am I doing wrong please? Just noting, that when I manually enter the url in web browser, it works fine - I get the response with geocoded address.