Sample code for 30+ languages & platforms
Visual FoxPro

HTTP POST x-www-form-urlencoded

Demonstrates how to send a simple x-www-form-urlencoded POST.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loHttp
LOCAL lcJsonStr
LOCAL loReq
LOCAL loResp
LOCAL lcResponseBody
LOCAL loFac
LOCAL lcFilepath

lnSuccess = 0

loHttp = CreateObject('Chilkat.Http')

lcJsonStr = "{ some json ... }"

loReq = CreateObject('Chilkat.HttpRequest')
* This query parameter just happens to be named "json" and contains JSON text.
loReq.AddParam("json",lcJsonStr)

* We can optionally add more query parameters. 
loReq.AddParam("abc","123")
loReq.AddParam("xml","<abc>123</abc>")

* Note: Just because we passed a query param named "json" or "xml" means nothing special.  It's still just
* a name=value query parameter..

loReq.HttpVerb = "POST"
loReq.ContentType = "application/x-www-form-urlencoded"

loResp = CreateObject('Chilkat.HttpResponse')
lnSuccess = loHttp.HttpReq("http://example.com/xyz/connect/report",loReq,loResp)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loReq
    RELEASE loResp
    CANCEL
ENDIF

IF (loResp.StatusCode <> 200) THEN
    ? "Hey, I didn't receive the expected response status code!"
    ? "status code = " + STR(loResp.StatusCode)
ENDIF

* Could be error text if the status code wasn't what we expected, or could be the response
* body you're seeking..
lcResponseBody = loResp.BodyStr
? lcResponseBody

loFac = CreateObject('Chilkat.FileAccess')
lcFilepath = "some file path"
lnSuccess = loFac.WriteEntireTextFile(lcFilepath,lcResponseBody,"utf-8",0)
IF (lnSuccess <> 1) THEN
    ? loFac.LastErrorText
ENDIF

RELEASE loHttp
RELEASE loReq
RELEASE loResp
RELEASE loFac