OpenSpecimen v6.2.RC2
Using the following code I can GET the details of a visit:
<?php $participantURL = 'https://openspecimen.kcc.tju.edu:8443/openspecimen/rest/ng/visits/406210'; $user = "XXXXXXX"; $passwd = "XXXXXXXX"; $userpass = $user . ":" . $passwd; //echo "\nUser/Pass: (" . $userpass . ")\n"; $userpassenc = base64_encode($userpass); //echo "\nUser/Pass Encoded (" . $userpassenc . ")\n"; $dataarrayenc = NULL; $ch = curl_init($participantURL); curl_setopt($ch, CURLOPT_VERBOSE, FALSE); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($ch, CURLOPT_POSTFIELDS, $dataarrayenc); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // ask for results to be returned curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($dataarrayenc), 'Authorization: Basic ' . $userpassenc)); curl_setopt($ch, CURLOPT_HEADER, FALSE); // curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE); // Send to remote and return data to caller. $result = curl_exec($ch); $status = curl_getinfo($ch); if ($result !== false) { echo "\n\nResult: (" . $result . ")\n\n"; $resultarr = json_decode($result,TRUE); print_r($resultarr); } else echo "\n\nCurl Error: (" . curl_error($ch) . ")\n\n"; curl_close($ch);Array ( [id] => 406210 [cpId] => 50 [eventId] => 403816 [name] => Blood Draw [eventLabel] => Blood draw [eventPoint] => 1 [eventPointUnit] => DAYS [status] => Complete [visitDate] => 1578067348000 [totalPendingSpmns] => 0 [pendingPrimarySpmns] => 0 [plannedPrimarySpmnsColl] => 0 [uncollectedPrimarySpmns] => 0 [unplannedPrimarySpmnsColl] => 0 [storedSpecimens] => 0 [notStoredSpecimens] => 0 [distributedSpecimens] => 0 [closedSpecimens] => 0 [cprId] => 238515 [ppid] => IT-TEST-0001 [cpTitle] => IT Testing of SPR's and other report types [cpShortTitle] => IT Test SPR [clinicalDiagnoses] => Array ( [0] => Unknown primary cancer ) [diagnosisList] => Array ( [0] => Array ( [id] => 71424 [value] => Unknown primary cancer [attribute] => clinical_diagnosis [props] => Array ( ) [activityStatus] => Active ) ) [clinicalStatus] => Not Specified [activityStatus] => Active [site] => SKCC Biobank [surgicalPathologyNumber] => IT-00001 [sprLocked] => [forceDelete] => )
Using the following code to upload an SPR in pdf format fails:
<?php $participantURL = "https://openspecimen.kcc.tju.edu:8443/openspecimen/rest/ng/visits/406210/spr-file"; $user = "XXXXXXX"; $passwd = "XXXXXXXX"; $userpass = $user . ":" . $passwd; $userpassenc = base64_encode($userpass); $dataarray["visitId"] = "406210"; $dataarray["file"] = "ORD.pdf"; $dataarrayenc = json_encode($dataarray); $ch = curl_init($participantURL); curl_setopt($ch, CURLOPT_VERBOSE, TRUE); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $dataarrayenc); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // ask for results to be returned curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($dataarrayenc), 'Authorization: Basic ' . $userpassenc)); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE); // Send to remote and return data to caller. $result = curl_exec($ch); $status = curl_getinfo($ch); echo "\n\nStatus:\n"; print_r(array($status)); echo "\n\nEnd Status\n"; if ($result !== false) { echo "\n\nResult: (" . $result . ")\n\n"; $resultarr = json_decode($result,TRUE); print_r($resultarr); } else echo "\n\nCurl Error: (" . curl_error($ch) . ")\n\n"; curl_close($ch);
This generates:
Status: Array ( [0] => Array ( [url] => https://openspecimen.kcc.tju.edu:8443/openspecimen/rest/ng/visits/406210/spr-file [content_type] => application/json [http_code] => 500 [header_size] => 539 [request_size] => 248 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.269277 [namelookup_time] => 0.00427 [connect_time] => 0.004589 [pretransfer_time] => 0.163202 [size_upload] => 37 [size_download] => 156 [speed_download] => 579 [speed_upload] => 137 [download_content_length] => -1 [upload_content_length] => 37 [starttransfer_time] => 0.264833 [redirect_time] => 0 [redirect_url] => [primary_ip] => 10.187.130.18 [certinfo] => Array ( ) [primary_port] => 8443 [local_ip] => 10.187.131.7 [local_port] => 35988 [request_header] => POST /openspecimen/rest/ng/visits/406210/spr-file HTTP/1.0 Host: openspecimen.kcc.tju.edu:8443 Accept: */* Content-Type: application/json Content-Length: 37 Authorization: Basic anByZWJlcjpNZXNhIzQyMA== ) ) End Status Result: ([{"code":"internal_error","message":"Sorry, something went wrong. Please report this error to the system administrator. Error: NullPointerException:null."}]) Array ( [0] => Array ( [code] => internal_error [message] => Sorry, something went wrong. Please report this error to the system administrator. Error: NullPointerException:null. )
From log file: 10.187.131.7 - - [07/Jan/2020:20:20:39 +0000] "POST /openspecimen/rest/ng/visits/406210/spr-file HTTP/1.0" 500 156