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