Querying XNAT database from command line

47 views
Skip to first unread message

Pablo Yepes

unread,
Nov 29, 2022, 10:17:05 AM11/29/22
to xnat_discussion
I am using http to query XNAT. I use 

http --session=XXXXXX GET $host/data/archive/projects/$project/subjects

to get a list of subjects in a particular project ($project).

I cannot figure out how to obtain a list of subject belonging to a particular group within the project. I did look at https://wiki.xnat.org/display/XAPI/XNAT+Search+API and other documentation, but I find it a little confusing. Any help would be appreciated.

akluiber

unread,
Nov 29, 2022, 7:08:45 PM11/29/22
to xnat_discussion
I've been working on figuring out something similar recently. Look at the examples here: https://wiki.xnat.org/display/XAPI/How+to+Query+the+XNAT+Search+Engine+with+REST+API

Here's what seems to work for me. Build a template for your query using subjects table in your project - edit/filter the columns you want, then copy/paste the xml (Options --> Show XML). I think you need to wipe out the bundle's ID. From there it seems you can reduce the xml document quite a bit. I've attached some examples.

I use curl, so my command looks like this: curl -u user:password -X POST "https://xnat.server/data/search?format=json" -F "file=@/path/to/query.xml"
reduced.xml
example.xml
Reply all
Reply to author
Forward
0 new messages