(Go) HTTP POST with Binary Data in Request Body
Do an HTTPS POST with a binary request body.
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := chilkat.NewHttp()
var success bool
fac := chilkat.NewFileAccess()
reqBody = fac.ReadEntireFile("qa_data/pdf/helloWorld.pdf")
responseStr := http.PostBinary("https://example.com/something",reqBody,"application/pdf",false,false)
if http.LastMethodSuccess() == false {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
fac.DisposeFileAccess()
return
}
responseStatusCode := http.LastStatus()
fmt.Println("Status code: ", responseStatusCode)
// For example, if the response is XML, JSON, HTML, etc.
fmt.Println("response body:")
fmt.Println(*responseStr)
http.DisposeHttp()
fac.DisposeFileAccess()
|