Classic ASP
Classic ASP
Send a Multipart REST Request
See more REST Examples
Demonstrates Rest.FullRequestMultipart, which sends a complete multipart request using the parts configured on the object, then returns the response body as text.
Background. Each multipart part is built by selecting it with the part selector, adding its header fields, and setting its body. FullRequestMultipart then assembles and sends all configured parts as a single multipart request.
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
' Configure a multipart request part before sending. PartSelector selects the part being built,
' and the header fields and body apply to that part.
rest.PartSelector = "1"
success = rest.AddHeader("Content-Type","text/plain")
success = rest.AddHeader("Content-Disposition","form-data; name=""field1""")
success = rest.SetMultipartBodyString("value1")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
Response.End
End If
' Send the multipart request using the configured parts. The response body is returned as text.
responseText = rest.FullRequestMultipart("POST","/api/upload")
If (rest.LastMethodSuccess = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( responseText) & "</pre>"
%>
</body>
</html>