Sample code for 30+ languages & platforms
PowerBuilder

Example: Http.SetUrlVar method

Demonstrates the HTTP SetUrlVar method.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Http
string ls_Url
oleobject loo_SbJson
integer li_StatusCode

li_Success = 0

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

ls_Url = "https://finnhub.io/api/v1/quote?symbol={$symbol}&token={$api_key}"

// When the request is sent, the {$symbol} is replaced with "MSFT"
// and the {$api_key} is replaced with "1234567890ABCDEF"
loo_Http.SetUrlVar("symbol","MSFT")
loo_Http.SetUrlVar("api_key","1234567890ABCDEF")

loo_SbJson = create oleobject
li_rc = loo_SbJson.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Http.QuickGetSb(ls_Url,loo_SbJson)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbJson
    return
end if

li_StatusCode = loo_Http.LastStatus
if li_StatusCode <> 200 then
    Write-Debug "Status code: " + string(li_StatusCode)
    Write-Debug "Error Message:"
    Write-Debug loo_SbJson.GetAsString()
else
    Write-Debug "JSON Stock Quote:"
    Write-Debug loo_SbJson.GetAsString()
end if

// Output:

// JSON Stock Quote:
// {"c":522.98,"d":0.5,"dp":0.0957,"h":524.51,"l":520.86,"o":524.28,"pc":522.48,"t":1755271948}


destroy loo_Http
destroy loo_SbJson