Я хочу использовать API анализа настроений Microsoft Azure. Я использую их пример кода (https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/quickstarts/python) следующим образом.
# -*- coding: utf-8 -*
import requests
# pprint is used to format the JSON response
from pprint import pprint
import os
subscription_key = "*********"
endpoint = "https://westcentralus.api.cognitive.microsoft.com/text/analytics"
sentiment_url = endpoint + "/text/analytics/v2.1/sentiment"
documents = {"documents": [
{"id": "1", "language": "en",
"text": "I had a wonderful experience! The rooms were wonderful and the staff was helpful."},
{"id": "2", "language": "en",
"text": "I had a terrible time at the hotel. The staff was rude and the food was awful."},
{"id": "3", "language": "es",
"text": "Los caminos que llevan hasta Monte Rainier son espectaculares y hermosos."},
{"id": "4", "language": "es",
"text": "La carretera estaba atascada. Había mucho tráfico el día de ayer."}
]}
headers = {"Ocp-Apim-Subscription-Key": subscription_key}
response = requests.post(sentiment_url, headers=headers, json=documents)
sentiments = response.json()
pprint(sentiments)
Но он возвращает только {'error': {'code': '404', 'message': 'Resource not found'}}
В чем проблема?