Classic ASP
Classic ASP
Send a REST Request using StringBuilder Bodies
See more REST Examples
Demonstrates Rest.FullRequestSb, which sends a complete request whose text body is read from a StringBuilder and stores the text response body in a second StringBuilder.
Background. Using StringBuilder objects for the request and response bodies avoids extra string conversions, which is helpful when working with large payloads.
Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
set rest = Server.CreateObject("Chilkat.Rest")
bTls = 1
bAutoReconnect = 1
success = rest.Connect("example.com",443,bTls,bAutoReconnect)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
Response.End
End If
' FullRequestSb sends a request whose text body is read from a StringBuilder and stores the text
' response body in a second StringBuilder. This avoids extra string conversions for large bodies.
set sbRequest = Server.CreateObject("Chilkat.StringBuilder")
success = sbRequest.Append("{ ""query"": ""chilkat"" }")
success = rest.AddHeader("Content-Type","application/json")
set sbResponse = Server.CreateObject("Chilkat.StringBuilder")
success = rest.FullRequestSb("POST","/api/search",sbRequest,sbResponse)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
Response.End
End If
responseText = sbResponse.GetAsString()
If (sbResponse.LastMethodSuccess = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( sbResponse.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( responseText) & "</pre>"
%>
</body>
</html>