Sample code for 30+ languages & platforms
Xbase++

HttpPostJson2 Example

See more HTTP Examples

Demonstrates use of the HttpPostJson2 method.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL cJsonBody
LOCAL oResp
LOCAL nStatusCode
LOCAL oJson

nSuccess := 0

//  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.

oHttp := CreateObject("Chilkat.Http")

//  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..
oHttp:AcceptCharset := ""
oHttp:UserAgent := ""
oHttp:AcceptLanguage := ""
oHttp:AllowGzip := 0

cJsonBody := '{"client_id": "PLAID_CLIENT_ID", "secret":"PLAID_SECRET", "count": 10, "offset": 0}'
oResp := oHttp:PostJson2("https://sandbox.plaid.com/institutions/get", "application/json", cJsonBody)
IF (oHttp:LastMethodSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    RETURN
ENDIF

nStatusCode := oResp:StatusCode
? "Response status code = " + Str(nStatusCode)

//  Examine the JSON response..
oJson := CreateObject("Chilkat.JsonObject")
oJson:Load(oResp:BodyStr)
oJson:EmitCompact := 0
? "JSON Response Body:"
? oJson:Emit()

oResp:destroy()

oHttp:destroy()
oJson:destroy()