python代码应如何使用请求包调用以下REST API?我不知道如何通过“ apikey”
curl -X POST -u "apikey":"1234abcd" -H "Accept: application/json" -F "file=@{input_file}" https://api_url
谢谢您的帮助。
您的curl命令可能适用于代码。当您不知道它支持什么时。您可以curl --help
或curl ... --trace-ascii 1.txt
用来弄清楚该过程
from requests.auth import HTTPBasicAuth
import requests
url = "https://api_url"
headers = {"Accept": "application/json"}
auth = HTTPBasicAuth('apikey', '1234abcd')
files = {'filename': open('filename','rb')}
req = requests.get(url, headers=headers , auth=auth , files=files)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句