Visual FoxPro
Visual FoxPro
Send a REST Request with a Text Body
See more REST Examples
Demonstrates Rest.FullRequestString, a convenience method that sends a complete request whose text body (such as JSON, XML, or plain text) is supplied directly, then reads and returns the response body as text.
Background. The full-request convenience methods perform the entire request/response exchange in a single call. FullRequestString is well suited to typical JSON or XML API calls where the body fits comfortably in a string.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loRest
LOCAL lnBTls
LOCAL lnBAutoReconnect
LOCAL lcJsonBody
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
* Send a complete request whose text body is supplied directly, such as JSON. The response body is
* read as text and returned. The 1st argument is the HTTP verb, the 2nd is the URI path, and the
* 3rd is the request body.
loRest.AddHeader("Content-Type","application/json")
lcJsonBody = '{ "name": "example", "active": true }'
lcResponseText = loRest.FullRequestString("POST","/api/items",lcJsonBody)
IF (loRest.LastMethodSuccess = 0) THEN
? loRest.LastErrorText
RELEASE loRest
CANCEL
ENDIF
? lcResponseText
RELEASE loRest