将此curl命令转换为Python请求

2024-09-27 00:23:07 发布

您现在位置:Python中文网/ 问答频道 /正文

工作旋度命令:

curl -i -XPATCH "https://api.threatstream.com/api/v1/intelligence/"
  -H "Content-Type: application/json"
  -H "Authorization: apikey email@email.com:password"
  --data @C:\Users\ghossh6\indicators.json

请求:

import requests

headers = {
    'Content-Type': 'application/json',
    'Authorization': 'apikey email@email.com:password',
}

data = open("C:/Users/ghossh6/indicators.json")
response = requests.patch('https://api.threatstream.com/api/v1/intelligence/', headers=headers, data=data)

响应

目前,我只收到502或405个错误代码。我尝试使用json.loads()来加载文件,但没有成功


Tags: httpscomapijsondataapplicationemailtype

热门问题