(Tcl) HTTP POST with Binary Data in Request Body
Do an HTTPS POST with a binary request body.
load ./chilkat.dll
# 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 responseStr [CkHttp_postBinary $http "https://example.com/something" $reqBody "application/pdf" 0 0]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
delete_CkFileAccess $fac
delete_CkByteData $reqBody
exit
}
set responseStatusCode [CkHttp_get_LastStatus $http]
puts "Status code: $responseStatusCode"
# For example, if the response is XML, JSON, HTML, etc.
puts "response body:"
puts "$responseStr"
delete_CkHttp $http
delete_CkFileAccess $fac
delete_CkByteData $reqBody
|