K
K
kolmi3232020-02-23 11:19:17
Python
kolmi323, 2020-02-23 11:19:17

Error vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: peer_id not integer. How to solve it?

I recently started learning python. I decided to write a bot, as planned, it should send pictures from a computer. Here is the code:

def main():
    for event in longpoll.listen():
        if event.type == VkEventType.MESSAGE_NEW:
            if event.to_me:
                request = event.text.lower()
                if request == '1':

                    a = vk.method("photos.getMessagesUploadServer")
                    b = requests.post(a['upload_url'], files={'photo': open('C:\data_for_bot\Bar.jpg', 'rb')}).json()
                    c = vk.method('photos.saveMessagesPhoto',{'photo': b['photo'], 'server': b['server'], 'hash': b['hash']})[0]
                    d = "photo{}_{}".format(c["owner_id"], c["id"])
                    vk.method("messages.send", {"peer_id": id, "message": "Bar", "attachment": d, "random_id": 0})

only at the end gives an error
vk_api.exceptions.ApiError: [100] One of the parameters specified was missing or invalid: peer_id not integer
What should I do and how to fix it?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question