What is the problem? Does not load the picture in the post Thanks in advance!

import os import vk import sys import requests import json session = vk.AuthSession(app_id='...', user_login='...', user_password='...', scope='wall, messages, photos') vk_api = vk.API(session, v='5.85') groupID = '172896425' upload_url = vk_api.photos.getWallUploadServer(group_id=groupID)['upload_url'] request = requests.post(upload_url, files={'photo': open('1.jpg', "rb")}) params = {'server': request.json()['server'], 'photo': request.json()['photo'], 'hash': request.json()['hash'], 'group_id': groupID} photo_id = vk_api.photos.saveWallPhoto(**params)[0]['id'] params = {'attachments': 'photo'+ groupID + '_'+ str(photo_id), 'message': 'test', 'owner_id': '-' + groupID, 'from_group': '1'} vk_api.wall.post(**params) 
  • What error crawls out? - fedotsoldier
  • Check the correctness of the attachments field - go to the page with the image in VC and look at the link - is it all the same as you have in the program - fedotsoldier
  • And do you need two stars before params - you don’t pass a variable number of arguments, but one - a dictionary with values - fedotsoldier
  • Error does not give any and the picture in the group does not appear - Gh Gf
  • Name "data" is not defined. Give the full code, please - cvetkoff

1 answer 1

In the last block, params did not pass the id

 photo_id = data [0]['id'] params = {'attachments': 'photo'+ str(data [0]['owner_id']) + '_'+ str(photo_id), 'message': 'test', 'owner_id': '-' + groupID, 'from_group': '1'}