Attention: : Confluence is not suitable for the storage of highly confidential data. Please ensure that any data classified as Highly Protected is stored using a more secure platform.
If you have any questions, please refer to the University's data classification guide or contact ict.askcyber@sydney.edu.au

4 Credentials using Cookies

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.

POST - /data/JSESSION

Parameters: Enter user credentials via calling mechanism, i.e:

$ curl -u username -X POST https://yourxnatdomain/data/JSESSION

Response: A new JSESSION ID string, for example:

3940FAAC4CB8DD368A9A1575372ECBBA

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/"

Enter host password for user 'username':

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 

"https://xnat.sydney.edu.au/data/archive/projects/PTV000/subjects/Haofei01/experiments/Haofei01_MR1/scans/4/resources/DICOM/files?format=zip" -o dicomfiles.zip

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100 22.8M    0 22.8M    0     0  5513k      0 --:--:--  0:00:04 --:--:-- 5514k