Answer the question
In order to leave comments, you need to log in
Why does 129 error appear when uploading a photo via vk api?
Good afternoon, there is a task to update a profile photo through a Python script.
To speed up work with api vk, I use this library: https://github.com/python273/vk_api
Here is the code:
from vk_api import *
vk = VkApi('login', 'password')
vk.authorization()
url = vk.method('photos.getOwnerPhotoUploadServer', {})['upload_url']
photos = ['1.jpg']
photos_files = open_photos(photos)
response = vk.http.post(url, files=photos_files).json()
close_photos(photos_files)
print vk.method('photos.saveOwnerPhoto', {
'server': response['server'],
'hash': response['hash'],
'photo': response['photo'],
})
File "/home/nikita/PycharmProjects/django/upload_photo.py", line 39, in handle
self.photo('1.jpg')
File "/home/nikita/PycharmProjects/django/upload_photo.py", line 29, in photo
print self.vk.method('photos.saveOwnerPhoto', values)
File "/usr/local/lib/python2.7/dist-packages/vk_api/vk_api.py", line 373, in method
raise error
vk_api.vk_api.ApiError: [129] Invalid photo: no "file" file, from upl_625624?act=owner_photo
Answer the question
In order to leave comments, you need to log in
When an error occurs when calling a method, it comes instead response
, error
and this field has a error["error_msg"]
, in which everything is written.
Try in some api method, right on the method page, call it with a deliberately incorrect input, you will understand what I mean.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question