Sample code for 30+ languages & platforms
PowerShell

Clear All Multipart Parts

See more REST Examples

Demonstrates Rest.ClearAllParts, which removes all multipart subparts from the request under construction.

Background. Clearing the parts is useful when reusing the same Rest object to build a different multipart request.

Chilkat PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

$rest = New-Object Chilkat.Rest
$bTls = $true
$bAutoReconnect = $true
$success = $rest.Connect("example.com",443,$bTls,$bAutoReconnect)
if ($success -eq $false) {
    $($rest.LastErrorText)
    exit
}

#  Build a part.
$rest.PartSelector = "1"
$success = $rest.SetMultipartBodyString("value1")
if ($success -eq $false) {
    $($rest.LastErrorText)
    exit
}

#  Remove all multipart subparts from the request under construction, for example before reusing the
#  same Rest object for a different multipart request.
$rest.ClearAllParts()

$("All multipart parts cleared.")