Sample code for 30+ languages & platforms
Visual FoxPro

Send a Form-URL-Encoded REST Request

See more REST Examples

Demonstrates Rest.FullRequestFormUrlEncoded, which sends an application/x-www-form-urlencoded request. The body is built from the query parameters added to the object, and the response body is returned as text.

Background. For a form-url-encoded request the accumulated parameters become the request body rather than the URL query string. This matches the encoding used by HTML form POSTs.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loRest
LOCAL lnBTls
LOCAL lnBAutoReconnect
LOCAL lcResponseText

lnSuccess = 0

loRest = CreateObject('Chilkat.Rest')
lnBTls = 1
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("example.com",443,lnBTls,lnBAutoReconnect)
IF (lnSuccess = 0) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

*  The application/x-www-form-urlencoded body is built from the query parameters added to the object.
loRest.AddQueryParam("username","alice")
loRest.AddQueryParam("action","login")

*  Send the form-url-encoded request.  The parameters become the request body rather than the URL
*  query string.
lcResponseText = loRest.FullRequestFormUrlEncoded("POST","/api/login")
IF (loRest.LastMethodSuccess = 0) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

? lcResponseText

RELEASE loRest