Sample code for 30+ languages & platforms
PowerBuilder

Clear All Request Headers on a REST Object

See more REST Examples

Demonstrates Rest.ClearAllHeaders, which removes every request header previously added to the object.

Background. Clearing headers is a convenient way to reset request state before reusing the same Rest object for an unrelated request.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Rest
integer li_BTls
integer li_BAutoReconnect

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

loo_Rest.AddHeader("Accept","application/json")
loo_Rest.AddHeader("X-Custom-Header","example-value")

//  Remove all request headers previously added to this object, for example before reusing the same
//  Rest object for a different request.
loo_Rest.ClearAllHeaders()

Write-Debug "All request headers cleared."


destroy loo_Rest