PowerBuilder
PowerBuilder
Add a Query Parameter from a StringBuilder
See more REST Examples
Demonstrates Rest.AddQueryParamSb, which adds or replaces a query parameter whose value is read from a StringBuilder. The 1st argument is the name and the 2nd is the StringBuilder.
Background. This variant is convenient when the parameter value has already been assembled in a StringBuilder, avoiding an extra conversion to a plain string.
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Rest
integer li_BTls
integer li_BAutoReconnect
oleobject loo_SbValue
string ls_ResponseText
li_Success = 0
loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest")
if li_rc < 0 then
destroy loo_Rest
MessageBox("Error","Connecting to COM object failed")
return
end if
// Connect to the REST server. The 3rd argument enables TLS (use 1 for HTTPS on port 443),
// and the 4th enables automatic reconnection if the connection is dropped between requests.
li_BTls = 1
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("example.com",443,li_BTls,li_BAutoReconnect)
if li_Success = 0 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
return
end if
// The parameter value can also be supplied from a StringBuilder. The 1st argument is the name and
// the 2nd is the StringBuilder holding the value.
loo_SbValue = create oleobject
li_rc = loo_SbValue.ConnectToNewObject("Chilkat.StringBuilder")
loo_SbValue.Append("chilkat rest")
loo_Rest.AddQueryParamSb("q",loo_SbValue)
ls_ResponseText = loo_Rest.FullRequestNoBody("GET","/api/search")
if loo_Rest.LastMethodSuccess = 0 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
destroy loo_SbValue
return
end if
Write-Debug ls_ResponseText
destroy loo_Rest
destroy loo_SbValue