neon-data-api icon indicating copy to clipboard operation
neon-data-api copied to clipboard

Error using byFileAOP

Open eastenw opened this issue 2 years ago • 3 comments

Hi, I'm trying to explore LiDAR data but am having problem when trying to run:

byFileAOP("DP1.30003.001", site="TREE",year = "2022", check.size =T)

Currently getting an error: Error: lexical error: invalid char in json text. <!DOCTYPE html PUBLIC "-//W3C// (right here) ------^

I am new to R, so I may be missing something. Thanks

eastenw avatar Feb 14 '23 17:02 eastenw

@eastenw Thanks for reaching out! I'm having some trouble replicating this error, so I have two suggestions for troubleshooting.

  1. Sometimes errors like this can happen when the download times out. Try increasing the timeout in R: options(timeout=300). The value is in seconds, the default is 60. Downloading NEON AOP data is slow, so increasing the timeout can help.
  2. If the timeout doesn't get rid of the error, can you run the code below and report back on what happens?
req <- httr::GET('https://data.neonscience.org/api/v0/data/DP1.30003.001/TREE/2022-06')
av <- jsonlite::fromJSON(httr::content(req, as='text'))
for(i in 1:nrow(av$data$files)) {
  res <- try(httr::HEAD(av$data$files$url[i]), silent=T)
  if(inherits(res, 'try-error')) {
    print(av$data$files$name[i])
  }
}

The first two lines grab the file metadata from the API, so if you have an error there we'll know there's a problem with your connection. If the first two lines are successful, then the for loop will tell us which file is throwing the error.

cklunch avatar Feb 14 '23 20:02 cklunch

Hi, thanks for getting back

There is a connection problem: req <- httr::GET('https://data.neonscience.org/api/v0/data/DP1.30003.001/TREE/2022-06') Error in curl::curl_fetch_memory(url, handle = handle) : schannel: next InitializeSecurityContext failed: SEC_E_INVALID_TOKEN (0x80090308) - The token supplied to the function is invalid

Please let me know if you have any suggestions.

eastenw avatar Feb 14 '23 21:02 eastenw

@eastenw Thanks for the additional info. The most likely scenario is that this has something to do with the security settings on either your machine or your network. It's very similar to what a couple of people have reported in #121 in the NEON-utilities repo.

Next things to try:

  • Clear your R environment and try again
  • Make sure your versions of curl and httr are up to date
  • Make sure your version of R is up to date
  • Try using a different network, especially if your work network has aggressive security
  • Adjust the firewall/security settings on your computer, or consult your IT department to do this

cklunch avatar Feb 15 '23 18:02 cklunch