A
A
Alexander Kolotov2021-04-16 12:14:02
Python
Alexander Kolotov, 2021-04-16 12:14:02

Why does an error appear when loading a picture in vk through standalone api Python without saving it to disk?

photo returns empty

for image_url in image_list:
        print(image)
        # request = requests.post(upload_url, files={'photo': open(image_name, 'rb')})
        r = requests.get(image_url)
        image_data = r.content
        request = requests.post(upload_url, files={'photo': image_data})
        print('request', request.json())


The following is displayed in the console:
upload_url https://pu.vk.com/c842629/ss2101/upload.php?act=do...
https://instagram.fhrk9-1.fna.fbcdn.net/v/t51. 2885...
request {'server': 842629, 'photo': '[]', 'hash': '9d511797f669b13fe72f72d878ef3be7'}

vk.exceptions.VkAPIError: 100. One of the parameters specified was missing or invalid: photos_list is invalid . request_params = {'method': 'photos.saveWallPhoto', 'oauth': '1', 'group_id': 'Group id here', 'v': '5.130', 'photo': '[]', 'server ': '232131', 'hash': '4a31212f31c436b4f774b88927406174'}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-04-16
@kolotovalexander

Does not see the name of the file and swears. Throw any

request = requests.post(upload_url, files={'photo': ('test.jpg', image_data)})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question