Sample code for 30+ languages & platforms
Tcl

Add Multiple Query Parameters from a Query String

See more REST Examples

Demonstrates Rest.AddQueryParams, which adds several query parameters at once from a query-string in the form field1=value1&field2=value2.

Background. This is a convenient shortcut for populating many parameters from a single pre-built query string rather than calling AddQueryParam repeatedly.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set rest [new_CkRest]

#  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.
set bTls 1
set bAutoReconnect 1
set success [CkRest_Connect $rest "example.com" 443 $bTls $bAutoReconnect]
if {$success == 0} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    exit
}

#  Add several query parameters at once from a query-string.  Use the form field1=value1&field2=value2.
set queryString "q=chilkat&limit=10&sort=asc"
set success [CkRest_AddQueryParams $rest $queryString]
if {$success == 0} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    exit
}

set responseText [CkRest_fullRequestNoBody $rest "GET" "/api/search"]
if {[CkRest_get_LastMethodSuccess $rest] == 0} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    exit
}

puts "$responseText"

delete_CkRest $rest