Sample code for 30+ languages & platforms
Classic ASP

POST application/x-www-form-urlencoded using REST API

See more REST Examples

Demonstrates how to send a POST with query params (x-www-form-urlencoded) using the Chilkat REST object.

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

set rest = Server.CreateObject("Chilkat.Rest")

' This example will send to https://www.chilkatsoft.com/echoPost.asp

' Make the initial connection (without sending a request yet).
bTls = 1
port = 443
bAutoReconnect = 1
success = rest.Connect("www.chilkatsoft.com",port,bTls,bAutoReconnect)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
    Response.End
End If

' Provide query params.
success = rest.AddQueryParam("firstName","John")
success = rest.AddQueryParam("lastName","Doe")
success = rest.AddQueryParam("company","Bisco Bits Ltd.")

responseStr = rest.FullRequestFormUrlEncoded("POST","/echoPost.asp")
If (rest.LastMethodSuccess <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
    Response.End
End If

' When successful, the response status code will equal 200.
If (rest.ResponseStatusCode <> 200) Then
    ' Examine the request/response to see what happened.
    Response.Write "<pre>" & Server.HTMLEncode( "response status code = " & rest.ResponseStatusCode) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "response status text = " & rest.ResponseStatusText) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "response header: " & rest.ResponseHeader) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "response body (if any): " & responseStr) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "---") & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "LastRequestStartLine: " & rest.LastRequestStartLine) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "LastRequestHeader: " & rest.LastRequestHeader) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( responseStr) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Success.") & "</pre>"

%>
</body>
</html>