Rlabkey webdav access failing with 401 unauthorized

LabKey Support Forum
Rlabkey webdav access failing with 401 unauthorized Marcel de Leeuw  2021-01-31 06:31
Status: Active
 

Hello,

We are unsuccessful acessing files on the labkey server through Rlabkey. Selectrows in a folder succeeds, bu then acessing files through webdav in the same folder for the same user (API key) fails with error code 401 (unauthorized). Aslo, webdav through the browser works fine. What needs to be configured for webdav through Rlabkey?

baseurl <- "http://bifx.mrmhealth.com:8080/labkey"
folderpath <- "/MRM Health/M002/Pre-clinical/E-00065 Rat"
setwd("~/labkey/M002/Pre-clinical")

library(Rlabkey)

labkey.mgx <- labkey.selectRows(
  baseUrl = baseurl,
  folderPath=folderpath, 
  schemaName="assay.General.Whole metagenome", 
  queryName="Runs", 
  viewName="", 
  colNameOpt="rname")
datafile <- gsub(".+@files/(.+)", "\\1", labkey.mgx$realtiveabundances)

labkey.webdav.get(
  baseUrl=baseurl,
  folderPath=folderpath,
  remoteFilePath=datafile,
  localFilePath="rat.mgx.tsv",
  overwrite=T)

Error in handleError(response, haltOnError) :
HTTP request was unsuccessful. Status code = 401, Error message = /_webdav/MRM Health/M002/Pre-clinical/E-00065 Rat/@files/assaydata/ca-mrm-bacteria-filtered-ra_2020_12_04_20_04.tsv

Thanks and regards

 
 
chetc (LabKey Support) responded:  2021-02-22 11:50

Hello,

Since you are still getting a 401 message, this means that there was an issue with Authorization. Can you tell me what roles that user that is experiencing the issue has? Are they an admin, dev, etc...

It could be the case that they do not have access, due to their current role.

Thanks,
Chet

 
Marcel de Leeuw responded:  2021-02-22 11:56

Hello Chet,

I am the site admin and I created the API key I am using with Rlabkey as such.

Thanks,

Marcel de Leeuw
MRM Health
Senior Principal Scientist, Bioinformatics

 
chetc (LabKey Support) responded:  2021-04-26 12:36
Status: Closed

Hello Marcel,

I apologize for the delay in between responses. We try to address our forums when we get a chance but it's been very busy lately.

Since you are the Site Admin that API key should work for grabbing files. I'm curious to know how you were passing in your API key in that R script? Did you add (below) to your script to pass in the key?

library(Rlabkey)
labkey.setDefaults(apiKey="apikey|apikeyapikeyapikeyapikeyapikey")

It thats not all of it above (in your first post), could you share your whole script with us? Be sure to obscure the APIKey and BaseURL.

Thanks,
Chet