Answer the question
In order to leave comments, you need to log in
How to upload documents to the wall in Vkontakte docs.getWallUploadServer?
Hello!
I can't upload documents to Vkontakte.
I make a request like this:
URIBuilder uriBuilder = new URIBuilder();
uriBuilder.setScheme("https").setHost("api.vk.com").setPath("/method/docs.getWallUploadServer")
.setParameter("access_token", Social.VK_SECRET)
.setParameter("group_id", Social.VK_GROUP_ID);
HttpResponse response = HttpConnectionAgent.connectResponseGet(uriBuilder);
http://cs610528.vk.com/upload.php?act=add_doc&mid=99949353&aid=-1&gid=110212647&hash=4768a65fdbfaea16f18dfcb2c58f25c1&rhash=2a7228076d410f28c096da07c3295f8f&api=1
MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
entityBuilder.setContentType(ContentType.MULTIPART_FORM_DATA);
entityBuilder.addBinaryBody("file", data, ContentType.create("image/gif"), fileName);
HttpClient client = HttpClientBuilder.create().build();
HttpResponse response = null;
HttpPost request = new HttpPost(uri);
try {
final HttpEntity entity = entityBuilder.build();
request.setEntity(entity);
response = client.execute(request);
} catch (IOException e) {
e.printStackTrace();
}
{"error":"unknown error"}
13:17:18,719 DEBUG headers:138 - http-outgoing-1 >> Accept-Encoding: gzip,deflate
13:17:18,721 DEBUG wire:72 - http-outgoing-1 >> "POST /upload.php?act=add_doc&mid=99949353&aid=-1&gid=110212647&hash=046734d292608d3b23106ce33daadc50&rhash=7a3123bccf83449e432346e7b40a882e&api=1 HTTP/1.1[\r][\n]"
13:17:18,722 DEBUG wire:72 - http-outgoing-1 >> "Content-Length: 64906[\r][\n]"
13:17:18,722 DEBUG wire:72 - http-outgoing-1 >> "Content-Type: multipart/form-data; boundary=747yWg6beQMzKZ-D7wN7wGA3OAXTf9lrrbAlOiNS; charset=ISO-8859-1[\r][\n]"
13:17:18,723 DEBUG wire:72 - http-outgoing-1 >> "Host: cs415827.vk.com[\r][\n]"
13:17:18,724 DEBUG wire:72 - http-outgoing-1 >> "Connection: Keep-Alive[\r][\n]"
13:17:18,725 DEBUG wire:72 - http-outgoing-1 >> "User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_40)[\r][\n]"
13:17:18,733 DEBUG wire:72 - http-outgoing-1 >> "Accept-Encoding: gzip,deflate[\r][\n]"
13:17:18,734 DEBUG wire:72 - http-outgoing-1 >> "[\r][\n]"
13:17:18,735 DEBUG wire:72 - http-outgoing-1 >> "--747yWg6beQMzKZ-D7wN7wGA3OAXTf9lrrbAlOiNS[\r][\n]"
13:17:18,735 DEBUG wire:72 - http-outgoing-1 >> "Content-Disposition: form-data; name="file"; filename="1.gif"[\r][\n]"
13:17:18,736 DEBUG wire:72 - http-outgoing-1 >> "Content-Type: application/octet-stream[\r][\n]"
13:17:18,736 DEBUG wire:72 - http-outgoing-1 >> "Content-Transfer-Encoding: binary[\r][\n]"
13:17:18,737 DEBUG wire:72 - http-outgoing-1 >> "[\r][\n]"
13:17:18,738 DEBUG wire:72 - http-outgoing-1 >> "GIF89a[0x94][0x2][0x94][0x2][0xf7][0x0][0x0][0x14][0xe][0x0]"[0x1c][0x0]2,[0x0]///
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