Ruby Requires Chilkat v11.0.0+
Ruby
HTTP POST with Binary Data in Request Body
See more HTTP Examples
Do an HTTPS POST with a binary request body.Chilkat Ruby Downloads
require 'chilkat'
success = false
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
http = Chilkat::CkHttp.new()
fac = Chilkat::CkFileAccess.new()
reqBody = Chilkat::CkByteData.new()
success = fac.ReadEntireFile("qa_data/pdf/helloWorld.pdf",reqBody)
resp = Chilkat::CkHttpResponse.new()
success = http.HttpBinary("POST","https://example.com/something",reqBody,"application/pdf",resp)
if (success == false)
print http.lastErrorText() + "\n";
exit
end
responseStatusCode = resp.get_StatusCode()
print "Status code: " + responseStatusCode.to_s() + "\n";
# For example, if the response is XML, JSON, HTML, etc.
print "response body:" + "\n";
print resp.bodyStr() + "\n";