I’m trying to use the UMLS Search REST API. I successfully retrieved the TGT and The ST. However, when trying to do a search as mentioned in the documentations, I got no response at all. Here’s my code:
<?php $service_ticket='xxx' //ST retrieve earlier $cURLConnection = curl_init(); curl_setopt($cURLConnection, CURLOPT_URL,"https://uts-ws.nlm.nih.gov/rest/search/current"); curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true); //avoid unable to get local issuer certificate $values = array( 'ticket' => $service_ticket, 'string' => 'C0162565' ); $params = http_build_query($values); curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, $params); $qresult = curl_exec($cURLConnection); curl_close($cURLConnection); $jsonArrayResponse = json_decode($qresult,true); print_r($jsonArrayResponse); ?>
Advertisement
Answer
The API expects a GET request, but using curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, $params);
is changing the request type to POST. removing this command and adding the parameters directly to the URL fixes the problem.