Sample code for 30+ languages & platforms
PowerBuilder

HTTP POST with some Params in URL and others in application/x-www-form-urlencoded Body

See more HTTP Examples

Demonstrates show to send an HTTP POST with some params in the URL, and others in the application/x-www-form-urlencoded Body

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
string ls_Url
oleobject loo_Http
oleobject loo_Req
oleobject loo_Resp

li_Success = 0

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

// Imagine a URL that contains two params: one named "xyz" and one named "name".
// We want to send a POST to it, but with 2 additional params in the body of the request.
ls_Url = "http://www.chilkatsoft.com/echoPost.asp?xyz=123&name=matt"

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Provide a session log path so we can visually verify the exact request sent.
// (This is only for debugging purposes.)
loo_Http.SessionLogFilename = "c:/temp/httpLog.txt"

// Create an HTTP request that has two additional params
loo_Req = create oleobject
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")

loo_Req.HttpVerb = "POST"
loo_Req.Path = "/echoPost.asp?xyz=123&name=matt"
loo_Req.AddParam("sport","tennis")
loo_Req.AddParam("tournament","French Open")

// Send the HTTP POST and get the response.
loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")

li_Success = loo_Http.HttpSReq("www.chilkatsoft.com",80,0,loo_Req,loo_Resp)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Req
    destroy loo_Resp
    return
end if

Write-Debug loo_Resp.BodyStr

Write-Debug "Success."


destroy loo_Http
destroy loo_Req
destroy loo_Resp