Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run R scripts on Nature Serve API #30

Open
mokezonline opened this issue Feb 16, 2024 · 3 comments
Open

Unable to run R scripts on Nature Serve API #30

mokezonline opened this issue Feb 16, 2024 · 3 comments

Comments

@mokezonline
Copy link

Session Info
Hey folks, I'm trying to obtain unique IDs for a csv of taxa. This is my test code using only canis lupis initially: # Install and load the devtools package (if not already installed) if (!requireNamespace("devtools", quietly = TRUE)) { install.packages("devtools") } library(devtools)

Install and load the natserv package from GitHub (if not already installed)

if (!requireNamespace("natserv", quietly = TRUE)) {
devtools::install_github("ropensci/natserv")
}
library(natserv)

gray.wolf.search <- ns_search_spp(x = "Canis lupus")
gray.wolf.search$globalSpeciesUid

Over repeated attempts I am consistently receiving a NULL output. I queried nature serve using postman via their example: explorer.natureserve.org/api/data/taxon/ELEMENT_GLOBAL.2.154701 HTTP/1.1
?Accept=application/json, just to see if I could get anything back, but it resulted in an internal server error code 500.

Is there something wrong with my code/query, or does this have something to do with Nature Serve servers being down?
Thanks!

@ChristopherTracey
Copy link
Contributor

Hi @mokezonline
Apologies for the delay in getting back to you. I believe that this is a code issue, as I noticed a few inconsistences in your example script. Here's my corrected version:

library(natserv)
gray.wolf.search <- ns_search_spp(text="Canis lupus")
gray.wolf.search$results$uniqueId

In the second line, you need to replace "x" with "text". Interestingly the code returns a set of 20 results if "text" is missing. I'm not sure if that's the expected behavior or not.

In the third line, you're missing the "results" part of the list object. Also the variable with the UID is 'uniqueId' not 'globalSpeciesUid.

Let me know if this helps. Also, I heard you also emailed NatureServe with a version of this question. I'll let my colleagues know that we hopefully solved it here.

@mokezonline
Copy link
Author

mokezonline commented Mar 4, 2024 via email

@mokezonline
Copy link
Author

mokezonline commented Mar 4, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants