Assuming your CURL is called from a TCL program, here is a snippet from something I did to help you understand the nature of what you get back.
First when configuring your curlHandle, include -headervar varname (sample below). This will get you header information returned from the call in an array, including the status code, i.e., 200 (success), 400 (not found), etc.
set curlHandle [curl::init]
$curlHandle configure -url $url -post 1 -postfields “$msg” -httpheader $httpHeaders -headervar httpHeader -bodyvar httpBody
When you perform the curl call, here is an excerpt from my code which checks for curl error, then checks for success, in my example above, httpBody will contain the return from the POST, so you’re processing will vary.
catch { $curlHandle perform } curlErrorNumber
if { $curlErrorNumber != 0 } {
echo “[curl::easystrerror $curlErrorNumber]”
} else {
set statCode [lindex [split $httpHeader(http) ” “] 1]
if {($statCode >= 100) && ($statCode <= 299)} {
#successful http transfer, echo return
regsub -all — {n} $httpBody {} ack
set fs [string index $ack 3]
set segs [split $ack r]
set MSA [lindex $segs [lsearch -regexp $segs {^MSA}]]
set ackcode [lindex [split $MSA $fs] 1]
if {$ackcode == "AA"} {
echo "Successful transfer"
lappend dispList "KILL $mh"
} else {
echo "HL7 NAK"
lappend dispList "ERROR $mh"
}
} else {
#failed http transfer, echo code
echo "$httpHeader(http)"
lappend dispList "ERROR $mh"
}
}
$curlHandle cleanup
Hope this helps,
Robert Milfajt
Northwestern Medicine
Chicago, IL