Lua
Lua
HttpPostJson2 Example
See more HTTP Examples
Demonstrates use of the HttpPostJson2 method.Chilkat Lua Downloads
local chilkat = require("chilkat")
local success = false
-- This requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code
-- See PostJson2Async Example for the async equivalent of this example.
local http = chilkat.Http.new()
-- Sends a POST equivalent to the following CURL command:
-- curl -X POST https://sandbox.plaid.com/institutions/get \
-- -H 'content-type: application/json' \
-- -d '{
-- "client_id": String,
-- "secret":String,
-- "count": Number,
-- "offset": Number
-- }'
-- Suppress some default headers that would automatically added..
ERROR: Property not in Chilkat for Lua: Http.AcceptCharset
http.AcceptCharset = ""
http.user_agent = ""
ERROR: Property not in Chilkat for Lua: Http.AcceptLanguage
http.AcceptLanguage = ""
http.allow_gzip = false
local jsonBody = "{\"client_id\": \"PLAID_CLIENT_ID\", \"secret\":\"PLAID_SECRET\", \"count\": 10, \"offset\": 0}"
local resp = ERROR: Method not in Chilkat for Lua: Http.PostJson2
http:ERROR()
if not http.last_method_success then
print(http.last_error_text)
return
end
local statusCode = resp.status_code
print("Response status code = " .. statusCode)
-- Examine the JSON response..
local json = chilkat.JsonObject.new()
json:load(resp.body_str)
json.emit_compact = false
print("JSON Response Body:")
print(json:emit())