Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Use Cookie to perform XNAT RESTAPI call

The reason for using this method is in the AAF, there wont be a "permanent“ username and password. But in order for us to use the AAF with RESTAPI credentials, Chapter 4 and Chapter 5.

1 Get A New User Session

This call allows for manual management of HTTP sessions within XNAT. This is particularly useful when you want to re-use the same session across multiple curl or XNATDataClient calls.

...

You can then use this JSESSION ID in a cookie in lieu of user credentials to authenticate subsequent calls, e.g.:

1.1 Get the SESSION Number via curl command line

[unikey@login2 NIFTI]$ curl -u username "https://xnat.sydney.edu.au/data/JSESSION/"

...

628EE7A19C8B9CEF7AE46E3744F6CXX

1.2 Get the SESSION Number via Web interface

Just logon the URL://data/JSESSION

List the project

[unikey@login2 NIFTI]$curl --cookie JSESSIONID=628EE7A19C8B9CEF7AE46E3744F6CXX https://xnat.sydney.edu.au/data/projects

{"ResultSet":{"Result":[{"pi_firstname":"","secondary_ID":"PTV000","pi_lastname":"","name":"PTV000","description":"","ID":"PTV000","URI":"/data/projects/PTV000"},{"pi_firstname":"","secondary_ID":"MS project","pi_lastname":"","name":"A prospective study investigating the clinical correlates of brain magnetic resonance imaging; T1, T2, Gd-DTPA, DWI (ADC/FA), perfusion and spectroscopy parameters in enhancing and non-enhancing MSl","description":"","ID":"2012_1047","URI":"/data/projects/2012_1047"},{"pi_firstname":"","secondary_ID":"ForeFront","pi_lastname":"","name":"ForeFront Ageing and Neurodegeneration","description":"Data from various studies run by the ForeFront group.","ID":"FF","URI":"/data/projects/FF"},{"pi_firstname":"","secondary_ID":"Preclinical Imaging","pi_lastname":"","name":"Preclinical Imaging","description":"Preclincial Imaging Core Facility Multimodal Projects","ID":"1","URI":"/data/projects/1"}], "totalRecords": "4"}}


Download the file

[unikey@login2 NIFTI]$curl --cookie JSESSIONID=628EE7A19C8B9CEF7AE46E3744F6CXX 

...