(Tcl) HTTP POST JSON
Demonstrates how to send a JSON POST and get the JSON response.
load ./chilkat.dll
# This requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code
set http [new_CkHttp]
set jsonText "{\"user\":\"doctoravatar@penzance.com\",\"forecast\":7,\"t\":\"vlIj\",\"zip\":94089}"
# IMPORTANT: Make sure to change the URL, JSON text,
# and other data items to your own values. The URL used
# in this example will not actually work.
# resp is a CkHttpResponse
set resp [CkHttp_PostJson $http "https://json.penzance.org/request" $jsonText]
if {[CkHttp_get_LastMethodSuccess $http] != 1} then {
puts [CkHttp_lastErrorText $http]
} else {
# Display the JSON response.
puts [CkHttpResponse_bodyStr $resp]
delete_CkHttpResponse $resp
}
delete_CkHttp $http
|