Let’s learn how to make requests to the Platform APIs with the help of an example. You can paste the command below into your terminal to run your first API request. Make sure to replace placeholders for Base URL, Token, Source, and path to your DICOM file with your actual data.
import requestsurl ="Base_URL/studies/"# Prepare the files for upload. Assign each file a unique key.files ={'file_0': ('<dicom_file1.dcm>',open('<path/to/dicom_file1.dcm>', 'rb'),'application/dicom'),'file_1': ('<dicom_file2.dcm>',open('<path/to/dicom_file2.dcm>', 'rb'),'application/dicom'),'file_2': ('<dicom_file3.dcm>',open('<path/to/dicom_file3.dcm>', 'rb'),'application/dicom')}# Headers, including the Authorization token and Sourceheaders ={'Authorization':'Token <PASTE_YOUR_TOKEN>','Source':'<PASTE_YOUR_SOURCE>','Content-Type':'multipart/form-data','User-Agent':'<YOUR_USER_AGENT>'}# Perform the POST requestresponse = requests.post(url, headers=headers, files=files)# Print the response textprint(response.text)# Close the file handles after the request is donefor file in files.values(): file[1].close()
When you make a request to the Platform APIs, the response includes two key components
HTTP Status Code: The HTTP status codes for all responses follow the RFC 9110 standard.
JSON Body: The JSON body contains detailed information about the response.
You can find specific information about the response format for each API, in the subsequent sections.