Answer the question
In order to leave comments, you need to log in
How to work with object of type multipart/form-data in Java 11?
I am writing in java 11 and for api requests I use the built-in java.net.http.HttpRequest; And now I want to upload a picture to the VK wall via api. According to the documentation, I need an object of the multipart/form-data type for this. I did not find how to work with such an object through java.net.http.HttpRequest. Therefore, I had a question with it is generally possible to work with it without loading any third-party libraries, but using pure Java 11 or not? If possible, how? My method looks like this now
try {
postRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
.POST(HttpRequest.BodyPublishers.noBody())
.header("Content-Type", "multipart/form-data")
.build();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question