namc-utah / NAMCr

NAMC Database and Analysis R API
MIT License
0 stars 0 forks source link

setSitePredictorValue failing from NAMCr #26

Open philipbaileynar opened 2 years ago

philipbaileynar commented 2 years ago

The corresponding API endpoint has been tested and confirmed to be working. Therefore it must be something to do with the NAMCr save(0 function again.

I am running NAMCr 0.7.5

The call:

result = mutation(
        api_endpoint = "setSitePredictorValue",
        args = list(siteId = 4407, predictorId = 130, value = "11.4")
    )
Screen Shot 2022-03-23 at 12 02 35 PM
philipbaileynar commented 2 years ago
#save each row in the database
for (i in 1:nrow(predsfinal)){
tryCatch({
if (predsfinal$isTemporal[i]==TRUE) {
NAMCr::save(
api_endpoint = "setSamplePredictorValue",
sampleId = predsfinal$sampleId[i],
predictorId = predsfinal$predictorId[i],
value = predsfinal$value[i]
)
} else{
NAMCr::save(
api_endpoint = "setSitePredictorValue",
siteId = predsfinal$siteId[i],
predictorId = predsfinal$predictorId[i],
value = predsfinal$value[i]
)
}
}, error = function(e) {
cat(paste0("\n\tERROR saving: ",predsfinal$sampleId[i]," ",predsfinal$predictorId[i],"\n"))
str(e,indent.str = " "); cat("\n")

})
}