Java
Java
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 Java Downloads
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
boolean success = false;
CkRest rest = new CkRest();
boolean bTls = true;
boolean bAutoReconnect = true;
success = rest.Connect("example.com",443,bTls,bAutoReconnect);
if (success == false) {
System.out.println(rest.lastErrorText());
return;
}
// Build a part.
rest.put_PartSelector("1");
success = rest.SetMultipartBodyString("value1");
if (success == false) {
System.out.println(rest.lastErrorText());
return;
}
// Remove all multipart subparts from the request under construction, for example before reusing the
// same Rest object for a different multipart request.
rest.ClearAllParts();
System.out.println("All multipart parts cleared.");
}
}