Sample code for 30+ languages & platforms
AutoIt

Set a Multipart Part Body from a String

See more REST Examples

Demonstrates Rest.SetMultipartBodyString, which sets the text body of the currently selected multipart part.

Background. A multipart request is assembled part by part: the part selector chooses the part being built, header fields describe it, and a SetMultipartBody method supplies its content. The request is then sent with a multipart send or full-request method.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

$oRest = ObjCreate("Chilkat.Rest")
Local $bTls = True
Local $bAutoReconnect = True
$bSuccess = $oRest.Connect("example.com",443,$bTls,$bAutoReconnect)
If ($bSuccess = False) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

;  Select the multipart part to build, and set its header fields.
$oRest.PartSelector = "1"
$oRest.AddHeader("Content-Disposition","form-data; name=""field1""")
$oRest.AddHeader("Content-Type","text/plain")

;  Set the text body of the selected multipart part.
$bSuccess = $oRest.SetMultipartBodyString("value1")
If ($bSuccess = False) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

;  Send the multipart request using the configured part(s).
Local $sResponseText = $oRest.FullRequestMultipart("POST","/api/upload")
If ($oRest.LastMethodSuccess = False) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite($sResponseText & @CRLF)