Am using a simple script to geocode a dataframe of addresses in R using my organization's enterprise geocoding server, but am getting an error indicating that my request is being directed to the default ArcGIS World Geocode Server and the request fails. Code is below, and was working as recently as this past March. I am successfully generating a token and connecting to the enterprise geocode server, all metadata appears in my environment, but the `geocode_addresses()` job fails.
library(arcgisutils)
library(arcgisgeocode)
library(dplyr)
arcgis_token <- arcgisutils::auth_code() ## complete OAuth2 in browser, get code
print(arcgis_token) ## confirm correct
set_arc_token(arcgis_token) ## set token as default
test <- tribble(~name, ~addr, ~id,
"info", "for", "testaddresses")
gc <- geocode_server("<enterprise server address>")
results <- geocode_addresses(
single_line = test$addr,
for_storage = FALSE,
geocoder = gc
)
And then I get the following error + traceback:
<error/rlang_error>
Error in `geocode_server()`:
! Status code: 498
Error: Invalid Token
---
Backtrace:
1. └─arcgisgeocode::geocode_addresses(...)
2. └─arcgisgeocode:::has_custom_fields(geocoder)
3. └─arcgisgeocode::world_geocoder()
4. └─arcgisgeocode::geocode_server("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer")
Additional notes:
- My ArcGIS server admin is stumped helping me troubleshoot this, as he does see my request against our enterprise server in his server log.
- If I run list_geocoders() after assigning my enterprise server to variable gc, I only see the ArcGIS World geocode server listed
- If I run default_geocoder(<my_token>), I get the error below:
<error/rlang_error>
Error in `geocode_server()`:
! Status code: 498
Error: Invalid Token
---
Backtrace:
1. └─arcgisgeocode::default_geocoder(arcgis_token)
2. └─arcgisgeocode::geocode_server(res[1, "url"])
3. └─arcgisutils::detect_errors(res)
4. └─rlang::abort(e_msg, call = error_call)
Any ideas would be appreciated. We already spoke to our ESRI tech support contact and he said they can't help with R and directed me here.
ARCGIS_CLIENT and ARCGIS_HOST are saved in my .REnviron. Using R 4.5.1 (also tried this in 4.3.3 and did not work) in RStudio IDE version 2025.05.1+513