Sample code for 30+ languages & platforms
Visual Basic 6.0

HTTP POST with Binary Data in Request Body

See more HTTP Examples

Do an HTTPS POST with a binary request body.

Chilkat Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

Dim http As New ChilkatHttp

Dim fac As New CkFileAccess

Dim reqBody() As Byte
reqBody = fac.ReadEntireFile("qa_data/pdf/helloWorld.pdf")

Dim resp As New ChilkatHttpResponse
success = http.HttpBinary("POST","https://example.com/something",reqBody,"application/pdf",resp)
If (success = 0) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Dim responseStatusCode As Long
responseStatusCode = resp.StatusCode
Debug.Print "Status code: " & responseStatusCode

' For example, if the response is XML, JSON, HTML, etc.
Debug.Print "response body:"
Debug.Print resp.BodyStr