简体   繁体   English

执行 python 请求后脚本时出错

[英]Error when executing a python requests post script

I'm not sure what i'm doing wrong with the script below, but i keep getting this error when i try to execute the script.我不确定我在下面的脚本中做错了什么,但是当我尝试执行该脚本时,我一直收到此错误。 any idea what i'm doing wrong?知道我做错了什么吗? thanks!谢谢!

在此处输入图像描述

import requests

blxr_endpoint = "https://bxgw-nd-061-866-537.p2pify.com"
authorization = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

blxr_request_json = {
    "method": "blxr_tx",
    "params": {
        "transaction": signed_txn.rawTransaction.hex()[2:],
    }
}

result = requests.post(blxr_endpoint,json = blxr_request_json,auth = authorization)

Less familiar with the auth param, but fromrequests docs the auth param doesn't get string as an input.不太熟悉auth参数,但是从请求文档中,auth 参数没有将字符串作为输入。 It supposed to get a class that inherits from requests.auth.AuthBase like:它应该得到一个 class 继承自requests.auth.AuthBase像:
HTTPBasicAuth HTTP基本认证
HTTPDigestAuth HTTPDigestAuth
OAuth1 OAuth1

and other(you can also create one yourself.)和其他(您也可以自己创建一个。)
Another option is to insert the Authorization header of the http manually:另一种选择是手动插入 http 的Authorization header:

result  = requests.post(blxr_endpoint, headers={'Authorization': authorization})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM