相关疑难解决方法(0)

我从 PYTHON 调用 API 我得到响应 406 Not Acceptable

我在我的站点中创建了一个 API,我试图从 python 调用一个 API,但我总是得到 406 作为响应,但是,如果我将 url 与参数一起放在浏览器中,我可以看到正确的答案

我已经在您可以测试自己的 API 的页面中进行了一些测试,我在浏览器中对其进行了测试并且工作正常。我已经跟进了一本手册,解释了如何从 python 调用 API,但我没有得到正确的响应:(

这是带有参数的 API 的 URL:https ://icassy.com/api/login.php ? usuario_email = warles34%40gmail.com & usuario_clave =123

这是我用来从 Python 调用 API 的代码

import requests
urlLogin = "https://icassy.com/api/login.php"
params = {'usuario_email': 'warles34@gmail.com', 'usuario_clave': '123'}
r = requests.get(url=urlLogin, data=params)
print(r)
print(r.content)
Run Code Online (Sandbox Code Playgroud)

我得到:

<Response [406]>
b'<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>'
Run Code Online (Sandbox Code Playgroud)

我应该以 JSON 格式接收成功消息和 apikey,如下所示:

{ …

python api request http-status-code-406

3
推荐指数
1
解决办法
3499
查看次数

标签 统计

api ×1

http-status-code-406 ×1

python ×1

request ×1