0

我需要上传一个json格式的rpt文件到api

我有一个有效的代码,但我无法用 python 复制它

jq '. | {schema: tojson}' test_api.rpt | \
curl -X POST http://api_url \
-H "Content-Type:application/json" \
-d @-

我的python脚本:

def json_to_subjects():
    url = "http://api_url"
    headers = {'Content-type': 'application/json'}
    data = json.dumps(open('reports/test_api.rpt').read())
    r = requests.post(url, data, headers=headers)
    return r.text

{"error_code":405,"message":"HTTP 405 Method Not Allowed"}在第一个代码有效时返回此错误

4

0 回答 0