bivashy / java-vk-bots-long-poll-api

A Java library to create VK bots using Bots Long Poll API
MIT License
3 stars 0 forks source link

Issue with downloading a document uploaded by a bot - file not found #100

Closed ventureoo closed 2 years ago

ventureoo commented 2 years ago

The document is uploaded normally, no Exception, but you can't download it - 404 error. The bot has the rights to upload files. I am also sure that the path to the file is correct.

Code:

package org.example;

import api.longpoll.bots.LongPollBot;
import api.longpoll.bots.exceptions.VkApiException;
import api.longpoll.bots.methods.impl.messages.Send;
import api.longpoll.bots.model.events.messages.MessageNew;
import api.longpoll.bots.model.objects.basic.Message;

import java.io.File;

public class ExampleBot  extends LongPollBot
{
    public static final String PATH = "/home/vasily/file_217.MP4";

    @Override
    public void onMessageNew(MessageNew messageNew) {
        try {
            Message message = messageNew.getMessage();
            if (message.hasText()) {
                Send.Response response = vk.messages.send()
                        .setPeerId(message.getPeerId())
                        .addDoc(new File(PATH))
                        .execute();
                System.out.println("Sync response: " + response);
            }
        } catch (VkApiException e) {
            e.printStackTrace();
        }
    }

    public static void main( String[] args ) throws VkApiException {
        new ExampleBot().startPolling();
    }

    @Override
    public String getAccessToken() {
        return "a7f5d77c2a96e682d32306c9f15b71b4d1caa425956efd333580fd02cc6589f1f32680dec9e8e4a2f947b";
    }
}

2022-04-24-142120_374x149_scrot 2022-04-24-142946_748x544_scrot

yvasyliev commented 2 years ago

Hi @ventureoo,

Could you please enable DEBUG level and share the logs when you execute this code?

Also please try to upload a different video file. Is result the same?

ventureoo commented 2 years ago

Hi.

I did the same thing with an ordinary photo and got the same result (though not 404, but just an empty file). See code and logs below.

package org.example;

import api.longpoll.bots.LongPollBot;
import api.longpoll.bots.exceptions.VkApiException;
import api.longpoll.bots.methods.impl.messages.Send;
import api.longpoll.bots.model.events.messages.MessageNew;
import api.longpoll.bots.model.objects.basic.Message;

import java.io.File;

public class ExampleBot  extends LongPollBot
{
    public static final String PATH = "/home/vasily/.wallpaper.jpg";

    @Override
    public void onMessageNew(MessageNew messageNew) {
        try {
            Message message = messageNew.getMessage();
            if (message.hasText()) {
                Send.Response response = vk.messages.send()
                        .setPeerId(message.getPeerId())
                        .addDoc(new File(PATH))
                        .execute();
                System.out.println("Sync response: " + response);
            }
        } catch (VkApiException e) {
            e.printStackTrace();
        }
    }

    public static void main( String[] args ) throws VkApiException {

        new ExampleBot().startPolling();
    }

    @Override
    public String getAccessToken() {
        return "a7f5d77c2a96e682d32306c9f15b71b4d1caa425956efd333580fd02cc6589f1f32680dec9e8e4a2f947b";
    }
}

Logs

/home/vasily/.jdks/corretto-1.8.0_312/bin/java -Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG -javaagent:/usr/share/idea/lib/idea_rt.jar=34305:/usr/share/idea/bin -Dfile.encoding=UTF-8 -classpath /home/vasily/.jdks/corretto-1.8.0_312/jre/lib/charsets.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/ext/cldrdata.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/ext/dnsns.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/ext/jaccess.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/ext/jfxrt.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/ext/localedata.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/ext/nashorn.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/ext/sunec.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/ext/sunjce_provider.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/ext/sunpkcs11.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/ext/zipfs.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/jce.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/jfr.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/jfxswt.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/jsse.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/management-agent.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/resources.jar:/home/vasily/.jdks/corretto-1.8.0_312/jre/lib/rt.jar:/home/vasily/IdeaProjects/testVkBot/target/classes:/home/vasily/.m2/repository/com/github/yvasyliev/java-vk-bots-longpoll-api/3.2.10/java-vk-bots-longpoll-api-3.2.10.jar:/home/vasily/.m2/repository/com/google/code/gson/gson/2.9.0/gson-2.9.0.jar:/home/vasily/.m2/repository/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar:/home/vasily/.m2/repository/org/slf4j/slf4j-simple/1.7.36/slf4j-simple-1.7.36.jar org.example.ExampleBot
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getById, Params={access_token=*************************************************************************************, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":[{"id":212886194,"name":"testbota","screen_name":"club212886194","is_closed":0,"type":"page","photo_50":"https:\/\/vk.com\/images\/community_50.png","photo_100":"https:\/\/vk.com\/images\/community_100.png","photo_200":"https:\/\/vk.com\/images\/community_200.png"}]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getLongPollServer, Params={access_token=*************************************************************************************, group_id=212886194, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"key":"431d6826ac62c705f6b4da7113824d2722883308","server":"https:\/\/lp.vk.com\/wh212886194","ts":"18"}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getLongPollServer, Params={access_token=*************************************************************************************, group_id=212886194, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"key":"d194b6a454aaf4daf19fb0e13ba8e0d6feb07e50","server":"https:\/\/lp.vk.com\/wh212886194","ts":"18"}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=431d6826ac62c705f6b4da7113824d2722883308, ts=18}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"ts":"19","updates":[{"group_id":212886194,"type":"message_new","event_id":"8e69a3f3fbc0ce8e9a7b90fae74494e01b2f0f2f","v":"5.131","object":{"message":{"date":1650817180,"from_id":370582630,"id":0,"out":0,"attachments":[],"conversation_message_id":32,"fwd_messages":[],"important":false,"is_hidden":false,"peer_id":2000000001,"random_id":0,"text":"test"},"client_info":{"button_actions":["text","vkpay","open_app","location","open_link","callback","intent_subscribe","intent_unsubscribe"],"keyboard":true,"inline_keyboard":true,"carousel":true,"lang_id":0}}}]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/docs.getMessagesUploadServer, Params={access_token=*************************************************************************************, type=doc, v=5.131, peer_id=2000000001}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"upload_url":"https:\/\/pu.vk.com\/c236331\/upload.php?act=add_doc_new&mid=-212886194&aid=-1&gid=0&type=0&peer_id=-212886194&rhash=7084338f7a46e30fc1cc84d4c4a380c0&api=1&server=236331&_origin=https%3A%2F%2Fapi.vk.com&_sig=a1873e8a05ce5cfa732f4eacd17c6808"}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://pu.vk.com/c236331/upload.php?act=add_doc_new&mid=-212886194&aid=-1&gid=0&type=0&peer_id=-212886194&rhash=7084338f7a46e30fc1cc84d4c4a380c0&api=1&server=236331&_origin=https%3A%2F%2Fapi.vk.com&_sig=a1873e8a05ce5cfa732f4eacd17c6808, Params={}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"file":"-212886194|0|-1|236331|cf67a7ed6a|jpg|359365|.wallpaper.jpg|40683a615cbff313fcd8404764755401|8d1ed0d0253b1fa7e171ad901c69d9bf|m_cf67a7ed6a||m:130x74,s:100x57,x:604x340,y:807x454,z:1280x720,o:3840x2160|eyJkaXNrIjozMSwicGVlcl9zZW5kZXIiOiItMjEyODg2MTk0In0="}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/docs.save, Params={access_token=*************************************************************************************, file=-212886194|0|-1|236331|cf67a7ed6a|jpg|359365|.wallpaper.jpg|40683a615cbff313fcd8404764755401|8d1ed0d0253b1fa7e171ad901c69d9bf|m_cf67a7ed6a||m:130x74,s:100x57,x:604x340,y:807x454,z:1280x720,o:3840x2160|eyJkaXNrIjozMSwicGVlcl9zZW5kZXIiOiItMjEyODg2MTk0In0=, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"type":"doc","doc":{"id":634831697,"owner_id":-212886194,"title":".wallpaper.jpg","size":359365,"ext":"jpg","date":1650817183,"type":4,"url":"https:\/\/vk.com\/doc-212886194_634831697?hash=EziDqMmmuEe8yLCRHWp30LQcjC9NMU2fo3HQyLkb6Ko&dl=FUZDCMRYHA3DCOJU:1650817183:1sQjyIh13RbyxNzPw2QZsUhSUdXk1tsMGJLVCLoZedT&api=1&no_preview=1","preview":{"photo":{"sizes":[{"src":"https:\/\/sun9-80.userapi.com\/c236331\/u-212886194\/d31\/-3\/m_cf67a7ed6a.jpg","width":130,"height":74,"type":"m"},{"src":"https:\/\/sun9-11.userapi.com\/c236331\/u-212886194\/d31\/-3\/s_cf67a7ed6a.jpg","width":100,"height":57,"type":"s"},{"src":"https:\/\/sun9-43.userapi.com\/c236331\/u-212886194\/d31\/-3\/x_cf67a7ed6a.jpg","width":604,"height":340,"type":"x"},{"src":"https:\/\/sun9-79.userapi.com\/c236331\/u-212886194\/d31\/-3\/y_cf67a7ed6a.jpg","width":807,"height":454,"type":"y"},{"src":"https:\/\/sun9-16.userapi.com\/c236331\/u-212886194\/d31\/-3\/z_cf67a7ed6a.jpg","width":1280,"height":720,"type":"z"},{"src":"https:\/\/sun9-60.userapi.com\/c236331\/u-212886194\/d31\/-3\/o_cf67a7ed6a.jpg","width":3840,"height":2160,"type":"o"},{"src":"https:\/\/sun9-60.userapi.com\/impf\/c236331\/u-212886194\/d31\/-3\/o_cf67a7ed6a.jpg?size=288x162&quality=90&sign=5e3c12ffb70d12f3aa65fda86454e65b&c_uniq_tag=IEji0ldzBudxphUL-3bmQvu5QyKeCijXOgADFrhl7Qk","width":288,"height":162,"type":"i"},{"src":"https:\/\/sun9-60.userapi.com\/impf\/c236331\/u-212886194\/d31\/-3\/o_cf67a7ed6a.jpg?size=192x108&quality=90&sign=2f09c9b8a58d0d0293a695eaf462e88e&c_uniq_tag=JGd8JokrGzybFIQahBffU8FtU9ZU3whAq33-27cOfyE","width":192,"height":108,"type":"d"}]}}}}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/messages.send, Params={access_token=*************************************************************************************, random_id=1549739357, attachment=doc-212886194_634831697, v=5.131, peer_id=2000000001}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":34}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=431d6826ac62c705f6b4da7113824d2722883308, ts=19}
Sync response: GenericResponse{responseObject=34}

Result

2022-04-24-192237_452x304_scrot

I tried the same thing, but send the file as a photo. And I got an exception :/

Code

package org.example;

import api.longpoll.bots.LongPollBot;
import api.longpoll.bots.exceptions.VkApiException;
import api.longpoll.bots.methods.impl.messages.Send;
import api.longpoll.bots.model.events.messages.MessageNew;
import api.longpoll.bots.model.objects.basic.Message;

import java.io.File;

public class ExampleBot  extends LongPollBot
{
    public static final String PATH = "/home/vasily/.wallpaper.jpg";

    @Override
    public void onMessageNew(MessageNew messageNew) {
        try {
            Message message = messageNew.getMessage();
            if (message.hasText()) {
                File photo = new File(PATH);
                if (photo.exists()) {
                    Send.Response response = vk.messages.send()
                            .setPeerId(message.getPeerId())
                            .addPhoto(photo)
                            .execute();
                    System.out.println("Sync response: " + response);
                }
            }
        } catch (VkApiException e) {
            e.printStackTrace();
        }
    }

    public static void main( String[] args ) throws VkApiException {

        new ExampleBot().startPolling();
    }

    @Override
    public String getAccessToken() {
        return "a7f5d77c2a96e682d32306c9f15b71b4d1caa425956efd333580fd02cc6589f1f32680dec9e8e4a2f947b";
    }
}

Log

[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getById, Params={access_token=*************************************************************************************, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":[{"id":212886194,"name":"testbota","screen_name":"club212886194","is_closed":0,"type":"page","photo_50":"https:\/\/vk.com\/images\/community_50.png","photo_100":"https:\/\/vk.com\/images\/community_100.png","photo_200":"https:\/\/vk.com\/images\/community_200.png"}]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getLongPollServer, Params={access_token=*************************************************************************************, group_id=212886194, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"key":"109f41e0af63225f4f887b69617322ce823dc24b","server":"https:\/\/lp.vk.com\/wh212886194","ts":"24"}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getLongPollServer, Params={access_token=*************************************************************************************, group_id=212886194, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"key":"950e03f02ed9f0bb7205a09fe5afa48462fd21e8","server":"https:\/\/lp.vk.com\/wh212886194","ts":"24"}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=109f41e0af63225f4f887b69617322ce823dc24b, ts=24}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"ts":"25","updates":[{"group_id":212886194,"type":"message_new","event_id":"ba0751e365ea8a8d7f25ece8d240e14ad5c2e735","v":"5.131","object":{"message":{"date":1650817999,"from_id":370582630,"id":0,"out":0,"attachments":[],"conversation_message_id":41,"fwd_messages":[],"important":false,"is_hidden":false,"peer_id":2000000001,"random_id":0,"text":"test"},"client_info":{"button_actions":["text","vkpay","open_app","location","open_link","callback","intent_subscribe","intent_unsubscribe"],"keyboard":true,"inline_keyboard":true,"carousel":true,"lang_id":0}}}]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/photos.getMessagesUploadServer, Params={access_token=*************************************************************************************, v=5.131, peer_id=2000000001}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"album_id":-64,"upload_url":"https:\/\/pu.vk.com\/c858116\/ss2174\/upload.php?act=do_add&mid=-212886194&aid=-64&gid=0&peer_id=-212886194&rhash=635a3c47ea4869d1ceac52b42b50fd73&api=1&method=message&mailphoto=1&server=858116&_origin=https%3A%2F%2Fapi.vk.com&_sig=6b5ab93fdef4058df7d78dea057e90fd","user_id":0,"group_id":212886194}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://pu.vk.com/c858116/ss2174/upload.php?act=do_add&mid=-212886194&aid=-64&gid=0&peer_id=-212886194&rhash=635a3c47ea4869d1ceac52b42b50fd73&api=1&method=message&mailphoto=1&server=858116&_origin=https%3A%2F%2Fapi.vk.com&_sig=6b5ab93fdef4058df7d78dea057e90fd, Params={}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"server":858116,"photo":"[{\"markers_restarted\":true,\"photo\":\"69b766668e:w\",\"sizes\":[],\"latitude\":0,\"longitude\":0,\"kid\":\"56b8b29fb38385613723d57a30429453\",\"sizes2\":[[\"s\",\"1b1e765703784175858fe19d38a475553cedc160b1680ed103546790\",\"-2873806013720871813\",75,42],[\"m\",\"52fb4b2f12b7828e35a271b07edcc2c7ed04cdb56e0b014161ad0cf9\",\"3289168132294470587\",130,73],[\"x\",\"4476920c2e3e2d9805847d478b17a22fd909e651435498af1d7d53ff\",\"6901897732268129677\",604,340],[\"y\",\"20d578c82d986417c6545229267364893fdbdbcb49a81eedf55a2649\",\"7486152877033452647\",807,454],[\"z\",\"250b708daec42943f1431cd16ff47f737ac4d8fba735b0e1fa046d91\",\"8110554616755103717\",1280,720],[\"w\",\"eb96d53caec8e0f3240009a43bd9c015473a742b8f3943172a8eeb8c\",\"-2776839307807412875\",2560,1440],[\"o\",\"d6370910293c553959d8a22ba6fbb3be2def88e6bfa8694a8ed20e8b\",\"-2834693885521711844\",130,87],[\"p\",\"086f5520af5e208ff9b5648b18a2b940ce018d16ab2252f434777a00\",\"-1649231559208134817\",200,133],[\"q\",\"ff8f6c1c9f3efe73eb2efd6a6722a11c278651b6898b34d9861bdee5\",\"3020360914654382507\",320,213],[\"r\",\"f33cffefbe3c4c34e61669fd0d9eca39c2bac7fd1317b65a9acf13bf\",\"-3410036562592697778\",510,340]],\"urls\":[],\"urls2\":[\"Gx52VwN4QXWFj-GdOKR1VTztwWCxaA7RA1RnkA/ezzJFqgwHtg.jpg\",\"UvtLLxK3go41onGwftzCx-0EzbVuCwFBYa0M-Q/u2vyU_14pS0.jpg\",\"RHaSDC4-LZgFhH1HixeiL9kJ5lFDVJivHX1T_w/jX3qb2t3yF8.jpg\",\"INV4yC2YZBfGVFIpJnNkiT_b28tJqB7t9VomSQ/Z_TY2WAo5Gc.jpg\",\"JQtwja7EKUPxQxzRb_R_c3rE2PunNbDh-gRtkQ/5acXz3N6jnA.jpg\",\"65bVPK7I4PMkAAmkO9nAFUc6dCuPOUMXKo7rjA/dS3Mo1yvdtk.jpg\",\"1jcJECk8VTlZ2KIrpvuzvi3viOa_qGlKjtIOiw/HK2BEu4kqdg.jpg\",\"CG9VIK9eII_5tWSLGKK5QM4BjRarIlL0NHd6AA/XxcJiaLAHOk.jpg\",\"_49sHJ8-_nPrLv1qZyKhHCeGUbaJizTZhhve5Q/q8ly0z966ik.jpg\",\"8zz_7748TDTmFmn9DZ7KOcK6x_0TF7Zams8Tvw/TnKRP9AdrdA.jpg\"],\"peer_id\":-212886194}]","hash":"b07d2962fcd1d2da65ce0a2098e85fa4"}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/photos.saveMessagesPhoto, Params={access_token=*************************************************************************************, server=858116, photo=[{"markers_restarted":true,"photo":"69b766668e:w","sizes":[],"latitude":0,"longitude":0,"kid":"56b8b29fb38385613723d57a30429453","sizes2":[["s","1b1e765703784175858fe19d38a475553cedc160b1680ed103546790","-2873806013720871813",75,42],["m","52fb4b2f12b7828e35a271b07edcc2c7ed04cdb56e0b014161ad0cf9","3289168132294470587",130,73],["x","4476920c2e3e2d9805847d478b17a22fd909e651435498af1d7d53ff","6901897732268129677",604,340],["y","20d578c82d986417c6545229267364893fdbdbcb49a81eedf55a2649","7486152877033452647",807,454],["z","250b708daec42943f1431cd16ff47f737ac4d8fba735b0e1fa046d91","8110554616755103717",1280,720],["w","eb96d53caec8e0f3240009a43bd9c015473a742b8f3943172a8eeb8c","-2776839307807412875",2560,1440],["o","d6370910293c553959d8a22ba6fbb3be2def88e6bfa8694a8ed20e8b","-2834693885521711844",130,87],["p","086f5520af5e208ff9b5648b18a2b940ce018d16ab2252f434777a00","-1649231559208134817",200,133],["q","ff8f6c1c9f3efe73eb2efd6a6722a11c278651b6898b34d9861bdee5","3020360914654382507",320,213],["r","f33cffefbe3c4c34e61669fd0d9eca39c2bac7fd1317b65a9acf13bf","-3410036562592697778",510,340]],"urls":[],"urls2":["Gx52VwN4QXWFj-GdOKR1VTztwWCxaA7RA1RnkA/ezzJFqgwHtg.jpg","UvtLLxK3go41onGwftzCx-0EzbVuCwFBYa0M-Q/u2vyU_14pS0.jpg","RHaSDC4-LZgFhH1HixeiL9kJ5lFDVJivHX1T_w/jX3qb2t3yF8.jpg","INV4yC2YZBfGVFIpJnNkiT_b28tJqB7t9VomSQ/Z_TY2WAo5Gc.jpg","JQtwja7EKUPxQxzRb_R_c3rE2PunNbDh-gRtkQ/5acXz3N6jnA.jpg","65bVPK7I4PMkAAmkO9nAFUc6dCuPOUMXKo7rjA/dS3Mo1yvdtk.jpg","1jcJECk8VTlZ2KIrpvuzvi3viOa_qGlKjtIOiw/HK2BEu4kqdg.jpg","CG9VIK9eII_5tWSLGKK5QM4BjRarIlL0NHd6AA/XxcJiaLAHOk.jpg","_49sHJ8-_nPrLv1qZyKhHCeGUbaJizTZhhve5Q/q8ly0z966ik.jpg","8zz_7748TDTmFmn9DZ7KOcK6x_0TF7Zams8Tvw/TnKRP9AdrdA.jpg"],"peer_id":-212886194}], v=5.131, hash=b07d2962fcd1d2da65ce0a2098e85fa4}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"error":{"error_code":1,"error_msg":"Unknown error occurred","request_params":[{"key":"method","value":"photos.saveMessagesPhoto"},{"key":"oauth","value":"1"},{"key":"server","value":"858116"},{"key":"v","value":"5.131"},{"key":"photo","value":"[{\"markers_restarted\":true,\"photo\":\"69b766668e:w\",\"sizes\":[],\"latitude\":0,\"longitude\":0,\"kid\":\"56b8b29fb38385613723d57a30429453\",\"sizes2\":[[\"s\",\"1b1e765703784175858fe19d38a475553cedc160b1680ed103546790\",\"-2873806013720871813\",75,42],[\"m\",\"52fb4b2f12b7828e35a271b07edcc2c7ed04cdb56e0b014161ad0cf9\",\"3289168132294470587\",130,73],[\"x\",\"4476920c2e3e2d9805847d478b17a22fd909e651435498af1d7d53ff\",\"6901897732268129677\",604,340],[\"y\",\"20d578c82d986417c6545229267364893fdbdbcb49a81eedf55a2649\",\"7486152877033452647\",807,454],[\"z\",\"250b708daec42943f1431cd16ff47f737ac4d8fba735b0e1fa046d91\",\"8110554616755103717\",1280,720],[\"w\",\"eb96d53caec8e0f3240009a43bd9c015473a742b8f3943172a8eeb8c\",\"-2776839307807412875\",2560,1440],[\"o\",\"d6370910293c553959d8a22ba6fbb3be2def88e6bfa8694a8ed20e8b\",\"-2834693885521711844\",130,87],[\"p\",\"086f5520af5e208ff9b5648b18a2b940ce018d16ab2252f434777a00\",\"-1649231559208134817\",200,133],[\"q\",\"ff8f6c1c9f3efe73eb2efd6a6722a11c278651b6898b34d9861bdee5\",\"3020360914654382507\",320,213],[\"r\",\"f33cffefbe3c4c34e61669fd0d9eca39c2bac7fd1317b65a9acf13bf\",\"-3410036562592697778\",510,340]],\"urls\":[],\"urls2\":[\"Gx52VwN4QXWFj-GdOKR1VTztwWCxaA7RA1RnkA\/ezzJFqgwHtg.jpg\",\"UvtLLxK3go41onGwftzCx-0EzbVuCwFBYa0M-Q\/u2vyU_14pS0.jpg\",\"RHaSDC4-LZgFhH1HixeiL9kJ5lFDVJivHX1T_w\/jX3qb2t3yF8.jpg\",\"INV4yC2YZBfGVFIpJnNkiT_b28tJqB7t9VomSQ\/Z_TY2WAo5Gc.jpg\",\"JQtwja7EKUPxQxzRb_R_c3rE2PunNbDh-gRtkQ\/5acXz3N6jnA.jpg\",\"65bVPK7I4PMkAAmkO9nAFUc6dCuPOUMXKo7rjA\/dS3Mo1yvdtk.jpg\",\"1jcJECk8VTlZ2KIrpvuzvi3viOa_qGlKjtIOiw\/HK2BEu4kqdg.jpg\",\"CG9VIK9eII_5tWSLGKK5QM4BjRarIlL0NHd6AA\/XxcJiaLAHOk.jpg\",\"_49sHJ8-_nPrLv1qZyKhHCeGUbaJizTZhhve5Q\/q8ly0z966ik.jpg\",\"8zz_7748TDTmFmn9DZ7KOcK6x_0TF7Zams8Tvw\/TnKRP9AdrdA.jpg\"],\"peer_id\":-212886194}]"},{"key":"hash","value":"b07d2962fcd1d2da65ce0a2098e85fa4"}]}}
api.longpoll.bots.exceptions.VkApiResponseException: {"error":{"error_code":1,"error_msg":"Unknown error occurred","request_params":[{"key":"method","value":"photos.saveMessagesPhoto"},{"key":"oauth","value":"1"},{"key":"server","value":"858116"},{"key":"v","value":"5.131"},{"key":"photo","value":"[{\"markers_restarted\":true,\"photo\":\"69b766668e:w\",\"sizes\":[],\"latitude\":0,\"longitude\":0,\"kid\":\"56b8b29fb38385613723d57a30429453\",\"sizes2\":[[\"s\",\"1b1e765703784175858fe19d38a475553cedc160b1680ed103546790\",\"-2873806013720871813\",75,42],[\"m\",\"52fb4b2f12b7828e35a271b07edcc2c7ed04cdb56e0b014161ad0cf9\",\"3289168132294470587\",130,73],[\"x\",\"4476920c2e3e2d9805847d478b17a22fd909e651435498af1d7d53ff\",\"6901897732268129677\",604,340],[\"y\",\"20d578c82d986417c6545229267364893fdbdbcb49a81eedf55a2649\",\"7486152877033452647\",807,454],[\"z\",\"250b708daec42943f1431cd16ff47f737ac4d8fba735b0e1fa046d91\",\"8110554616755103717\",1280,720],[\"w\",\"eb96d53caec8e0f3240009a43bd9c015473a742b8f3943172a8eeb8c\",\"-2776839307807412875\",2560,1440],[\"o\",\"d6370910293c553959d8a22ba6fbb3be2def88e6bfa8694a8ed20e8b\",\"-2834693885521711844\",130,87],[\"p\",\"086f5520af5e208ff9b5648b18a2b940ce018d16ab2252f434777a00\",\"-1649231559208134817\",200,133],[\"q\",\"ff8f6c1c9f3efe73eb2efd6a6722a11c278651b6898b34d9861bdee5\",\"3020360914654382507\",320,213],[\"r\",\"f33cffefbe3c4c34e61669fd0d9eca39c2bac7fd1317b65a9acf13bf\",\"-3410036562592697778\",510,340]],\"urls\":[],\"urls2\":[\"Gx52VwN4QXWFj-GdOKR1VTztwWCxaA7RA1RnkA\/ezzJFqgwHtg.jpg\",\"UvtLLxK3go41onGwftzCx-0EzbVuCwFBYa0M-Q\/u2vyU_14pS0.jpg\",\"RHaSDC4-LZgFhH1HixeiL9kJ5lFDVJivHX1T_w\/jX3qb2t3yF8.jpg\",\"INV4yC2YZBfGVFIpJnNkiT_b28tJqB7t9VomSQ\/Z_TY2WAo5Gc.jpg\",\"JQtwja7EKUPxQxzRb_R_c3rE2PunNbDh-gRtkQ\/5acXz3N6jnA.jpg\",\"65bVPK7I4PMkAAmkO9nAFUc6dCuPOUMXKo7rjA\/dS3Mo1yvdtk.jpg\",\"1jcJECk8VTlZ2KIrpvuzvi3viOa_qGlKjtIOiw\/HK2BEu4kqdg.jpg\",\"CG9VIK9eII_5tWSLGKK5QM4BjRarIlL0NHd6AA\/XxcJiaLAHOk.jpg\",\"_49sHJ8-_nPrLv1qZyKhHCeGUbaJizTZhhve5Q\/q8ly0z966ik.jpg\",\"8zz_7748TDTmFmn9DZ7KOcK6x_0TF7Zams8Tvw\/TnKRP9AdrdA.jpg\"],\"peer_id\":-212886194}]"},{"key":"hash","value":"b07d2962fcd1d2da65ce0a2098e85fa4"}]}}
    at api.longpoll.bots.methods.impl.VkMethod.execute(VkMethod.java:120)
    at api.longpoll.bots.helpers.attachments.MessagePhotoAttachable.attach(MessagePhotoAttachable.java:58)
    at api.longpoll.bots.methods.impl.messages.Send.execute(Send.java:62)
    at org.example.ExampleBot.onMessageNew(ExampleBot.java:25)
    at api.longpoll.bots.VkBot.lambda$handle$0(VkBot.java:68)
    at java.util.ArrayList.forEach(ArrayList.java:1259)
    at api.longpoll.bots.VkBot.handle(VkBot.java:64)
    at api.longpoll.bots.LongPollBot.startPolling(LongPollBot.java:63)
    at org.example.ExampleBot.main(ExampleBot.java:36)
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=109f41e0af63225f4f887b69617322ce823dc24b, ts=25}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"ts":"25","updates":[]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=109f41e0af63225f4f887b69617322ce823dc24b, ts=25}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"ts":"25","updates":[]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=109f41e0af63225f4f887b69617322ce823dc24b, ts=25}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"ts":"25","updates":[]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=109f41e0af63225f4f887b69617322ce823dc24b, ts=25}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"ts":"25","updates":[]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=109f41e0af63225f4f887b69617322ce823dc24b, ts=25}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"ts":"25","updates":[]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=109f41e0af63225f4f887b69617322ce823dc24b, ts=25}

When I upload a photo manually, everything is fine. 2022-04-24-194742_497x261_scrot

ventureoo commented 2 years ago

It's the same with upload the other video files.

yvasyliev commented 2 years ago

From your logs I see that the response to docs.getMessagesUploadServer or photos.getMessagesUploadServer method contains upload_url with this value: peer_id=-212886194. -212886194 - is your group_id.

I'm not sure that this is an expected result, because when I test your code example I see peer_id=<my_user_id>.

Could you please share an additional info:

  1. What artifact version you are using? (java-vk-bots-longpoll-api dependency)
  2. Are you using dialog or chat to communicate with your bot?
ventureoo commented 2 years ago

@yvasyliev

  1. I am using the latest version of your API according to the readme:
        <dependency>
            <groupId>com.github.yvasyliev</groupId>
            <artifactId>java-vk-bots-longpoll-api</artifactId>
            <version>3.2.10</version>
        </dependency>
  1. Yes, this is a group chat.
ventureoo commented 2 years ago

@yvasyliev Yes, that seems to be my slip. If you specify a chat id instead of a peer id when sending a photo, there is no exception. But the problem with sending documents remains.

ventureoo commented 2 years ago

So, now when I set peer_id according to VK API (2000000000 + chat id), I get an exception when uploading the document:

[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getById, Params={access_token=*************************************************************************************, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":[{"id":212886194,"name":"testbota","screen_name":"club212886194","is_closed":0,"type":"page","photo_50":"https:\/\/vk.com\/images\/community_50.png","photo_100":"https:\/\/vk.com\/images\/community_100.png","photo_200":"https:\/\/vk.com\/images\/community_200.png"}]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getLongPollServer, Params={access_token=*************************************************************************************, group_id=212886194, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"key":"2f1539db515b0db32a6894c01a5ccde2cd1e3b8c","server":"https:\/\/lp.vk.com\/wh212886194","ts":"34"}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getLongPollServer, Params={access_token=*************************************************************************************, group_id=212886194, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"key":"649e4d0fdce53bfa653a0196183802e47f887f5c","server":"https:\/\/lp.vk.com\/wh212886194","ts":"34"}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=2f1539db515b0db32a6894c01a5ccde2cd1e3b8c, ts=34}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"ts":"35","updates":[{"group_id":212886194,"type":"message_new","event_id":"064c0b77bb57617f36bdfe526ce24835351a9491","v":"5.131","object":{"message":{"date":1650831896,"from_id":370582630,"id":0,"out":0,"attachments":[],"conversation_message_id":56,"fwd_messages":[],"important":false,"is_hidden":false,"peer_id":2000000001,"random_id":0,"text":"asd"},"client_info":{"button_actions":["text","vkpay","open_app","location","open_link","callback","intent_subscribe","intent_unsubscribe"],"keyboard":true,"inline_keyboard":true,"carousel":true,"lang_id":0}}}]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/docs.getMessagesUploadServer, Params={access_token=*************************************************************************************, type=doc, v=5.131, peer_id=0}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"error":{"error_code":100,"error_msg":"One of the parameters specified was missing or invalid: peer_id is required for community messages","request_params":[{"key":"method","value":"docs.getMessagesUploadServer"},{"key":"oauth","value":"1"},{"key":"v","value":"5.131"},{"key":"type","value":"doc"},{"key":"peer_id","value":"0"}]}}
api.longpoll.bots.exceptions.VkApiResponseException: {"error":{"error_code":100,"error_msg":"One of the parameters specified was missing or invalid: peer_id is required for community messages","request_params":[{"key":"method","value":"docs.getMessagesUploadServer"},{"key":"oauth","value":"1"},{"key":"v","value":"5.131"},{"key":"type","value":"doc"},{"key":"peer_id","value":"0"}]}}
    at api.longpoll.bots.methods.impl.VkMethod.execute(VkMethod.java:120)
    at api.longpoll.bots.helpers.attachments.MessageDocAttachable.attach(MessageDocAttachable.java:49)
    at api.longpoll.bots.methods.impl.messages.Send.execute(Send.java:62)
    at org.example.ExampleBot.onMessageNew(ExampleBot.java:24)
    at api.longpoll.bots.VkBot.lambda$handle$0(VkBot.java:68)
    at java.util.ArrayList.forEach(ArrayList.java:1259)
    at api.longpoll.bots.VkBot.handle(VkBot.java:64)
    at api.longpoll.bots.LongPollBot.startPolling(LongPollBot.java:63)
    at org.example.ExampleBot.main(ExampleBot.java:33)

(Sorry for the mistake with the peer id, I was inattentive)

yvasyliev commented 2 years ago

@ventureoo, could you please test this code by sending a message to a dialog:

@Override
public void onMessageNew(MessageNew messageNew) {
    try {
        Message message = messageNew.getMessage();
        if (message.hasText()) {
            Send.Response response = vk.messages.send()
                    .setPeerId(message.getPeerId())
                    .addDoc(new File(PATH))
                    .execute();
            System.out.println("Sync response: " + response);
        }
    } catch (VkApiException e) {
        e.printStackTrace();
    }
}

Is result the same?

ventureoo commented 2 years ago

@yvasyliev The document is uploaded, but again we return to the original problem - the file is not found, 404.

[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getById, Params={access_token=*************************************************************************************, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":[{"id":212886194,"name":"testbota","screen_name":"club212886194","is_closed":0,"type":"page","photo_50":"https:\/\/vk.com\/images\/community_50.png","photo_100":"https:\/\/vk.com\/images\/community_100.png","photo_200":"https:\/\/vk.com\/images\/community_200.png"}]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getLongPollServer, Params={access_token=*************************************************************************************, group_id=212886194, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"key":"533e0653d0c9c0584d7eea5c1e0d297518ea10ee","server":"https:\/\/lp.vk.com\/wh212886194","ts":"37"}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/groups.getLongPollServer, Params={access_token=*************************************************************************************, group_id=212886194, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"key":"cc6dfb578a29bd83a3e7a95895a877ca3a6a3f9a","server":"https:\/\/lp.vk.com\/wh212886194","ts":"37"}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=533e0653d0c9c0584d7eea5c1e0d297518ea10ee, ts=37}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"ts":"38","updates":[{"group_id":212886194,"type":"message_new","event_id":"47cf56c881d64373730d8f31b5735c60d9b33327","v":"5.131","object":{"message":{"date":1650832830,"from_id":370582630,"id":0,"out":0,"attachments":[],"conversation_message_id":60,"fwd_messages":[],"important":false,"is_hidden":false,"peer_id":2000000001,"random_id":0,"text":"asd"},"client_info":{"button_actions":["text","vkpay","open_app","location","open_link","callback","intent_subscribe","intent_unsubscribe"],"keyboard":true,"inline_keyboard":true,"carousel":true,"lang_id":0}}}]}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/docs.getMessagesUploadServer, Params={access_token=*************************************************************************************, type=doc, v=5.131, peer_id=2000000001}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"upload_url":"https:\/\/pu.vk.com\/c235031\/upload.php?act=add_doc_new&mid=-212886194&aid=-1&gid=0&type=0&peer_id=-212886194&rhash=f10b318dc944d58365afc496e6d72bcf&api=1&server=235031&_origin=https%3A%2F%2Fapi.vk.com&_sig=6a596446257fd684154a657d44d9c328"}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://pu.vk.com/c235031/upload.php?act=add_doc_new&mid=-212886194&aid=-1&gid=0&type=0&peer_id=-212886194&rhash=f10b318dc944d58365afc496e6d72bcf&api=1&server=235031&_origin=https%3A%2F%2Fapi.vk.com&_sig=6a596446257fd684154a657d44d9c328, Params={}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"file":"-212886194|0|-1|235031|64a01ea18b|png|85497|2022-04-24-194742_497x261_scrot.png|3febce6b79bb882ba09ea79ba03d882b|52562d50521eab32f7e54d9a2c779f2c|m_64a01ea18b||m:130x69,s:100x53,o:497x261,x:497x261|eyJkaXNrIjo1LCJwZWVyX3NlbmRlciI6Ii0yMTI4ODYxOTQifQ=="}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/docs.save, Params={access_token=*************************************************************************************, file=-212886194|0|-1|235031|64a01ea18b|png|85497|2022-04-24-194742_497x261_scrot.png|3febce6b79bb882ba09ea79ba03d882b|52562d50521eab32f7e54d9a2c779f2c|m_64a01ea18b||m:130x69,s:100x53,o:497x261,x:497x261|eyJkaXNrIjo1LCJwZWVyX3NlbmRlciI6Ii0yMTI4ODYxOTQifQ==, v=5.131}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":{"type":"doc","doc":{"id":634854117,"owner_id":-212886194,"title":"2022-04-24-194742_497x261_scrot.png","size":85497,"ext":"png","date":1650832830,"type":4,"url":"https:\/\/vk.com\/doc-212886194_634854117?hash=uRjynk52hgFdKXJRlAH6AcnwjnM0jgXLMxMQUVi1DKz&dl=FUZDCMRYHA3DCOJU:1650832830:o6JdP4mZzLhn0ez2ezVn6HcMFKvih2tDSzbzqP8hjao&api=1&no_preview=1","preview":{"photo":{"sizes":[{"src":"https:\/\/sun9-40.userapi.com\/c235031\/u-212886194\/d5\/-3\/m_64a01ea18b.jpg","width":130,"height":69,"type":"m"},{"src":"https:\/\/sun9-36.userapi.com\/c235031\/u-212886194\/d5\/-3\/s_64a01ea18b.jpg","width":100,"height":53,"type":"s"},{"src":"https:\/\/sun9-86.userapi.com\/c235031\/u-212886194\/d5\/-3\/o_64a01ea18b.jpg","width":497,"height":261,"type":"o"},{"src":"https:\/\/sun9-78.userapi.com\/c235031\/u-212886194\/d5\/-3\/x_64a01ea18b.jpg","width":497,"height":261,"type":"x"},{"src":"https:\/\/sun9-86.userapi.com\/impf\/c235031\/u-212886194\/d5\/-3\/o_64a01ea18b.jpg?size=288x151&quality=90&sign=c61f7714d09a86bd00d8f866b4fa2692&c_uniq_tag=-DeP_6kWp0KgMf6aHOTUsA386EApw1_jTGqRr8SI1sQ","width":288,"height":151,"type":"i"},{"src":"https:\/\/sun9-86.userapi.com\/impf\/c235031\/u-212886194\/d5\/-3\/o_64a01ea18b.jpg?size=192x101&quality=90&sign=48fa3154b5afa21ac4f096c59ace1e93&c_uniq_tag=XylcE0603EhW2OV21RX9O03Q0PC0MDc4n0pFvy39HqQ","width":192,"height":101,"type":"d"}]}}}}}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://api.vk.com/method/messages.send, Params={access_token=*************************************************************************************, random_id=1565388621, attachment=doc-212886194_634854117, v=5.131, peer_id=2000000001}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Response: Status Code=200, Body={"response":62}
[main] DEBUG api.longpoll.bots.methods.impl.VkMethod - Request: Method=POST, URL=https://lp.vk.com/wh212886194, Params={wait=25, act=a_check, key=533e0653d0c9c0584d7eea5c1e0d297518ea10ee, ts=38}
Sync response: GenericResponse{responseObject=62}

2022-04-24-234216_449x288_scrot

yvasyliev commented 2 years ago

I still don't like that docs.getMessagesUploadServer returns peer_id=-212886194 as upload_url. I will try to contact VK support to get more info.

ventureoo commented 2 years ago

@yvasyliev OK, thank you!

yvasyliev commented 2 years ago

Hello @ventureoo, please check the answer from VK support:

File uploading is not supported in chats created by communities.

Can you try to create a chat by your user, and then add a community bot to this chat?

ventureoo commented 2 years ago

Yep, it's working now. Thanks again. 2022-04-27-155336_480x269_scrot

P.S. Maybe you should mention this not-so-obvious limitation in the README?