ropensci / natserv

:warning: ARCHIVED :warning: NatureServe R client
Other
11 stars 7 forks source link

Unable to run R scripts on Nature Serve API #30

Open mokezonline opened 8 months ago

mokezonline commented 8 months ago
Session Info ```r ```

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 commented 8 months ago

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 commented 8 months ago

Thank you so much for getting back to me, this helps a lot! Cheers, Zach

On Thu, Feb 22, 2024 at 7:30 PM Christopher Tracey @.***> wrote:

Hi @mokezonline https://github.com/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.

— Reply to this email directly, view it on GitHub https://github.com/ropensci/natserv/issues/30#issuecomment-1960652030, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJPN7EHN3VHRWN7VTY4TIG3YU75M3AVCNFSM6AAAAABDMXX5XKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRQGY2TEMBTGA . You are receiving this because you were mentioned.Message ID: @.***>

mokezonline commented 8 months ago

I just want to make sure that this is the right place to reference for the nat_serve functions: https://github.com/ropensci/natserv/tree/master/R

On Sun, Mar 3, 2024 at 8:54 PM Zachary Cush @.***> wrote:

Thank you so much for getting back to me, this helps a lot! Cheers, Zach

On Thu, Feb 22, 2024 at 7:30 PM Christopher Tracey < @.***> wrote:

Hi @mokezonline https://github.com/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.

— Reply to this email directly, view it on GitHub https://github.com/ropensci/natserv/issues/30#issuecomment-1960652030, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJPN7EHN3VHRWN7VTY4TIG3YU75M3AVCNFSM6AAAAABDMXX5XKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRQGY2TEMBTGA . You are receiving this because you were mentioned.Message ID: @.***>