просто пытаюсь отправить простой запрос к API естественного языка в python, и я не могу понять, почему он не работает; код:
import requests
import json
apikey = *Blanked*
URL = "https://language.googleapis.com/v1/documents:analyzeSentiment?key=" + apikey
content = {
"type": "PLAIN_TEXT",
"content": "Inception is one of the shittest movies of all time. I think no-one should watch it."
}
request_raw = {
"document": content,
"encodingType": "UTF8"
}
json_package = json.dumps(request_raw)
r = requests.post(url = URL, params = json_package)
api_response = r.json()
print(api_response)
Ошибка, которую я получаю:
{'error': {'code': 400, 'message': 'Invalid JSON payload received. Unknown name "{"document": {"type": "PLAIN_TEXT", "content": "Inception is one of the shittest movies of all time. I think no-one should watch it."}, "encodingType": "UTF8"}": Cannot bind query parameter. Field \'{"document": {"type": "PLAIN_TEXT", "content": "Inception is one of the shittest movies of all time\' could not be found in request message.', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'description': 'Invalid JSON payload received. Unknown name "{"document": {"type": "PLAIN_TEXT", "content": "Inception is one of the shittest movies of all time. I think no-one should watch it."}, "encodingType": "UTF8"}": Cannot bind query parameter. Field \'{"document": {"type": "PLAIN_TEXT", "content": "Inception is one of the shittest movies of all time\' could not be found in request message.'}]}]}}