Answer the question
In order to leave comments, you need to log in
How to fix error code 1 vk_api?
Good day, I'm trying to put a large amount of pictures on the page through VK api, I do everything with the help of this code:
import vk
import sys
session = vk.Session(access_token ="")
vk_a = vk.API(session , v= '5.92', lang = 'ru')
# Список с ссылками на картинки
hrefs = [
r'C:\Users\Никита\Pictures\4K Stogram\dariarebeshchenko\1970-01-01 03.00.00 .jpg',
]
for href in hrefs:
vk_a.wall.post(attachments = hrefs , message = '1' , owner_id = '')
Traceback (most recent call last):
File "main.py", line 14, in <module>
vk_a.wall.post(attachments = hrefs , message = '1' , owner_id = '')
File "C:\Users\Никита\AppData\Local\Programs\Python\Python36\lib\site-packages\vk\api.py", line 173, in __call__
return self._api._session.make_request(self)
File "C:\Users\Никита\AppData\Local\Programs\Python\Python36\lib\site-packages\vk\api.py", line 102, in make_request
raise error
vk.exceptions.VkAPIError: 1. Unknown error occurred. request_params = {'method': 'wall.post', 'oauth': '1', 'v': '5.92', 'lang': 'ru', 'attachments': 'C:\\Users\\Никита\\Pictures\\4K Stogram\\dariarebeshchenko\\1970-01-01 03.00.00 .jpg', 'message': '1', 'owner_id': ''}
Answer the question
In order to leave comments, you need to log in
Absolutely wrong method of sending images.
1. wall.post accepts lines of the form in the attachments field <type><owner_id>_<media_id>
, but not the path to the file on the PC
https://dev.vk.com/method/wall.post
2. First, the images must be uploaded to the VK server. Or look at the examples in the library, all of a sudden there are loading methods there, but in the general case this is done like this:
upload_url
, to which you will need to send an image of type multipart/form-data
POST by the method, again, if the library has its own methods of sending, send through it, if not, then somerequests
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question