Random Famous Quotes

FREEMIUM
От Andres Olvera | Обновлено 3 месяца назад | Data
Популярность

9.3 / 10

Задержка

281ms

Уровень обслуживания

100%

Назад ко всем обсуждениям

Error - Response 406

avatar
epodwyer
2 года назад

I am using Python and Requests to access the API. This was working fine. Now when I try to access the GET end point, with my API key, I get a HTML 406 Response.

“Test Endpoint” on Random Famous Quotes API Documentation works but it will not work with Python and Requests from the command line.

avatar
andruxnet commented 2 года назад

Hi,

Can you share your relevant Python and command line code?

avatar
epodwyer commented 2 года назад

import requests

api_host = "andruxnet-random-famous-quotes.p.rapidapi.com"
api_key = 'from rapidapi console’
api_url = “https://andruxnet-random-famous-quotes.p.rapidapi.com/?cat=famous&count=10

headers = {“X-RapidAPI-Host”:api_host, “X-RapidAPI-Key”: api_key}
response = requests.get(api_url, headers = headers)

The response is error 406= ‘<head><title>Not Acceptable!</title></head><body><h1>Not Acceptable!</h1><p>An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security.</p></body></html>’

I’m using python3.

Thanks for your help

Any update please?

avatar
payamazadi-natgeo commented 2 года назад

I’m having the same problem.
def get_quote():
response = requests.get(
https://andruxnet-random-famous-quotes.p.rapidapi.com/?cat=famous&count=10’,
headers={
‘x-rapidapi-host’: ‘andruxnet-random-famous-quotes.p.rapidapi.com’,
‘x-rapidapi-key’: ‘(removed)’
}
)
print(vars(response))

avatar
payamazadi-natgeo commented 2 года назад

Looks like it works when I add a User-agent’ key to the headers. It was a random guess. Not sure why it works from curl without a user-agent header, unless curl adds one by default (and maybe so does unirest).

avatar
epodwyer commented 2 года назад

Thanks, adding User-agent to the header works for me too.

Присоединяйтесь к обсуждению – добавьте комментарий ниже:

Войдите / Зарегистрируйтесь, чтобы публиковать новые комментарии
Оценки: 4.6 - Голосов: 5