VBScript
VBScript
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 VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
set rest = CreateObject("Chilkat.Rest")
bTls = 1
bAutoReconnect = 1
success = rest.Connect("example.com",443,bTls,bAutoReconnect)
If (success = 0) Then
outFile.WriteLine(rest.LastErrorText)
WScript.Quit
End If
' The application/x-www-form-urlencoded body is built from the query parameters added to the object.
success = rest.AddQueryParam("username","alice")
success = rest.AddQueryParam("action","login")
' Send the form-url-encoded request. The parameters become the request body rather than the URL
' query string.
responseText = rest.FullRequestFormUrlEncoded("POST","/api/login")
If (rest.LastMethodSuccess = 0) Then
outFile.WriteLine(rest.LastErrorText)
WScript.Quit
End If
outFile.WriteLine(responseText)
outFile.Close