C
C
chainikk2018-07-15 22:31:24
Python
chainikk, 2018-07-15 22:31:24

Need help with python code, wk_api. What could be the problem?

import requests
token = ''
data = requests.get(' https://api.vk.com/method/messages.getLongPollServer ',
params={'access_token': token}).json()['response']
print (data)
Error in KeyError: 'response', what could be?
Maybe I didn't specify something?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Max Payne, 2018-07-16
@YardalGedal

You have not specified all the parameters. Because of this, VKontakte does not return a response, but returns an error.
To see the error and what exactly is missing, use

data = requests.get('https://api.vk.com/method/messages.getLongPollServer',
params={'access_token': token}).json()

print(data)

A
Anatoly, 2018-07-15
@trofimovdev

To avoid such problems, use the .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question