Sample code for 30+ languages & platforms
Lianja Requires Chilkat v11.0.0+

Transition from Http.PostJson2 to Http.HttpStr

Provides instructions for replacing deprecated PostJson2 method calls with HttpStr.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

loHttp = createobject("CkHttp")

lcUrl = "https://example.com/something"
lcContentType = "application/json"
lcJsonText = "{ ... }"

//  ------------------------------------------------------------------------
//  The PostJson2 method is deprecated:

loResponseObj = loHttp.PostJson2(lcUrl,lcContentType,lcJsonText)
if (loHttp.LastMethodSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    return
endif

//  ...
//  ...

release loResponseObj

//  ------------------------------------------------------------------------
//  Do the equivalent using HttpStr.
//  Your application creates a new, empty HttpResponse object which is passed 
//  in the last argument and filled upon success.

loResponseOut = createobject("CkHttpResponse")
llSuccess = loHttp.HttpStr("POST",lcUrl,lcJsonText,"utf-8",lcContentType,loResponseOut)
if (llSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loResponseOut
    return
endif



release loHttp
release loResponseOut