Sample code for 30+ languages & platforms
DataFlex

Transition from Http.PostUrlEncoded to Http.HttpReq

Provides instructions for replacing deprecated PostUrlEncoded method calls with HttpReq.

Sends the following raw HTTP request:

POST /echoPost.asp HTTP/1.1
Host: www.chilkatsoft.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 50

company=example&ip=111.111.111.111&url=example.com

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    String sUrl
    Variant vReq
    Handle hoReq
    Variant vResponseObj
    Handle hoResponseObj
    Variant vReq
2    Handle hoReq2
    Variant vResp
    Handle hoResp
    String sTemp1
    Boolean bTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Move "https://www.chilkatsoft.com/echoPost.asp" To sUrl

    Get Create (RefClass(cComChilkatHttpRequest)) To hoReq
    If (Not(IsComObjectCreated(hoReq))) Begin
        Send CreateComObject of hoReq
    End
    Send ComAddParam To hoReq "company" "example"
    Send ComAddParam To hoReq "ip" "111.111.111.111"
    Send ComAddParam To hoReq "url" "example.com"

    // ------------------------------------------------------------------------
    // The PostUrlEncoded method is deprecated:

    Get pvComObject of hoReq to vReq
    Get ComPostUrlEncoded Of hoHttp sUrl vReq To vResponseObj
    If (IsComObject(vResponseObj)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResponseObj
        Set pvComObject Of hoResponseObj To vResponseObj
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // ...
    // ...

    Send Destroy of hoResponseObj

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

    Get Create (RefClass(cComChilkatHttpRequest)) To hoReq2
    If (Not(IsComObjectCreated(hoReq2))) Begin
        Send CreateComObject of hoReq2
    End
    Send ComAddParam To hoReq2 "company" "example"
    Send ComAddParam To hoReq2 "ip" "111.111.111.111"
    Send ComAddParam To hoReq2 "url" "example.com"

    Set ComHttpVerb Of hoReq2 To "POST"
    Set ComContentType Of hoReq2 To "application/x-www-form-urlencoded"

    Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
    If (Not(IsComObjectCreated(hoResp))) Begin
        Send CreateComObject of hoResp
    End
    Get pvComObject of hoReq2 to vReq2
    Get pvComObject of hoResp to vResp
    Get ComHttpReq Of hoHttp sUrl vReq2 vResp To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Results are contained in the HTTP response object...


End_Procedure