Tcl Requires Chilkat v11.0.0+
Tcl
HTTP POST with Binary Data in Request Body
See more HTTP Examples
Do an HTTPS POST with a binary request body.Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set http [new_CkHttp]
set fac [new_CkFileAccess]
set reqBody [new_CkByteData]
set success [CkFileAccess_ReadEntireFile $fac "qa_data/pdf/helloWorld.pdf" $reqBody]
set resp [new_CkHttpResponse]
set success [CkHttp_HttpBinary $http "POST" "https://example.com/something" $reqBody "application/pdf" $resp]
if {$success == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
delete_CkFileAccess $fac
delete_CkByteData $reqBody
delete_CkHttpResponse $resp
exit
}
set responseStatusCode [CkHttpResponse_get_StatusCode $resp]
puts "Status code: $responseStatusCode"
# For example, if the response is XML, JSON, HTML, etc.
puts "response body:"
puts [CkHttpResponse_bodyStr $resp]
delete_CkHttp $http
delete_CkFileAccess $fac
delete_CkByteData $reqBody
delete_CkHttpResponse $resp