Ah, I see. I took a look at the Edit Set area of the Sample Set I'm trying to insert into ('Study Specimens') and the Name Expression field is blank. I tried specifying some different name expressions in the Edit Set interface including ${Name} and ${randomID} and then trying to to insert samples again with the same procedure as before, but with no luck. Same error message occurs--'Name expression required'.
After setting the 'Name Expression' field back to its default value (which is empty in the HIV tutorial), I tried two different things while I was messing around with this over the weekend. First, per your suggestion, I made a data frame with a single row consisting of a single column ('Name') and tried to insert that. Same error.
folder = '/Tutorials/HIV Study'
schema = 'samples'
query = 'Study Specimens'
session <- getSession(baseUrl=base, folderPath=folder)
# Make a data frame that specifies a sample name
sampleToUpload = data.frame(matrix(c('P666666'), nrow=1))
colnames(sampleToUpload)=c('Name')
# Doesn't work, returns 'HTTP request was unsuccessful. Status code = 400, Error message = Name expression required'
labkey.insertRows(baseUrl=base, folderPath=folder,schemaName=schema, queryName=query, sampleToUpload)
Secondly, I navigated to the 'Upload Specimens' page, downloaded the template workbook, and entered data for a dummy sample (see attached Excel sheet). When I paste that sheet into the 'Upload Specimens' section I can add the sample just fine. When I read it into an R data frame first and try to insert it via API however I still get the same Name Expression error:
#Using template provided from the 'Upload Specimens' page
library(gdata)
sampleToUpload = read.xls('myHIVspecimen')
# Doesn't work, returns 'HTTP request was unsuccessful. Status code = 400, Error message = Name expression required'
labkey.insertRows(baseUrl=base, folderPath=folder,schemaName=schema, queryName=query, sampleToUpload)
You mentioned that the error didn't replicate for you. Can I ask what columns you passed in the data frame when you made the insertRows call so I can make sure I'm structuring my data frame correctly?