Python请求得到:“未指定动态后端主机" [英] Python requests get: "Dynamic backend host not specified"

查看:113
本文介绍了Python请求得到:“未指定动态后端主机"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用python的requests包做一个非常简单的https"get"方法,并且看来可行,除了我从主机收到一条错误消息,说:

I am trying to do a very simple https "get" method using python's requests package, and it seems to work, except that I get an error message from the host machine saying:

"Dynamic backend host not specified"

我不知道那到底是什么意思.在get方法中是否需要设置一些参数?

I don't know exactly what that means. Is there some parameter that needs to be set in the get method?

推荐答案

好吧,事实证明,这是正确设置标题的问题.

Okay, it turns out that it's a matter of setting up the headers correctly.

添加

headers = {'content-type': 'application/json', 'accept':'application/json'}

解决了这个问题.

该工作呼叫的代码:

r = requests.post(
    HELLO_WORLD_URL,
    cert = (os.path.join(CERT_DIR, "cert.pem"), os.path.join(CERT_DIR, "example-key.pem")),
    auth = (USER_ID, PASSWORD),
    headers = {'content-type': 'application/json', 'accept':'application/json'})

这篇关于Python请求得到:“未指定动态后端主机"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆