Dear Friends,
I have really tried everything but i cannot translate the JAVA code into VB.net. Could anybody translate this? A big golden star for the final solution:
I have really tried everything but i cannot translate the JAVA code into VB.net. Could anybody translate this? A big golden star for the final solution:
Code:
import java.io.File;
import javax.ws.rs.core.MediaType;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.methods.multipart.StringPart;
public class MultipartRecord
{
public static void main(String[] args)
{
try
{
File f = new File("c:\\csvs\\image1.jpg");
HttpClient client = new HttpClient();
PostMethod postMethod = new
PostMethod("[URL unfurl="true"]http://localhost/networking/rest/record/HOMEPAGE/");[/URL]
postMethod.setRequestHeader("Cookie", "JSESSIONID=A741270662A86F796DA16646F0708C43");
FilePart filePart = new FilePart("image_field", f);
filePart.setContentType(MediaType.APPLICATION_OCTET_STREAM);
StringPart sp = new StringPart("__xml_data__",
"<platform><record><field1>Some text field</field1>"
+ "<image_field>image1.jpg</image_field></record></platform>");
sp.setContentType(MediaType.APPLICATION_XML);
final Part[] parts = { sp, filePart };
postMethod.setRequestEntity(new MultipartRequestEntity(parts, postMethod.getParams()));
int executeMethod = client.executeMethod(postMethod);
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}