proxies = {
'http': f'{self.doc.http_proxy_url}:{self.doc.http_proxy_port}',
https': f'{self.doc.http_proxy_url}:{self.doc.http_proxy_port}'
}
requestHeaders1 = {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json;charset=UTF-8',
'tenant': '07da27b9-e911-4d2e-826c-2a4feeb4f35a'
}
with open('Ingest_APMAlarms.json') as json_file:
json_data = json.load(json_file)
url1 = apmEnvAttr.alerts_ingestion_url
r1 = requests.post(url1,
verify=False,
proxies=proxies,
headers=requestHeaders1,
json=json.dumps(json_data)),
当我使用邮递员执行相同的请求时,它会返回有效的json响应,但是当我尝试通过代码时,它将返回500响应。 Ingest_APMAlarms.json文件的内容如下所示。
"taskList": [
{
"taskId": "ABC_25_b5d2da6f-17ff-4476-9652-5e64e3c68381|9|100|9_1|2656",
"type": "upsertAlarm",
"body": {
"name": "NetDDE Exporter Failed to Start.",
"source": "System1",
"sourceKey": "DS-S1C-25_b5d2da6f-17ff-4476-9652-5e64e3c68381_9_100_9_1_test25Final",
"templated": "false",
"templateName": "System1_Events",
"severity": 0,
"eventStart": "2018-07-05T21:03:52.638",
"associatedMonitoredEntitySourceKey": "DS-S1C-25_b5d2da6f-17ff-4476-9652-5e64e3c68381",
"incident": {},
"tagsOfInterest": {
"uuid": "DS-S1C-25_b5d2da6f-17ff-4476-9652-5e64e3c68381_System1",
"isContributing": "true",
"displayGrouped": "true",
"displayGroupName": "System1",
"uom": "uom"
},
"enterpriseName": "DS-S1C-25",
"enterpriseId": "DS-S1C-25_b5d2da6f-17ff-4476-9652-5e64e3c68381",
"daqId": "9_1",
"assetNamePath": "DS-S1C-25->System1",
"assetPath": "DS-S1C-25->100",
"machineTrainName": null,
"machineTrainId": null,
"machineName": null,
"machineId": "100",
"trainMachine": "",
"pointName": null,
"pointId": null,
"nodeName": "System1",
"eventCategory": "system",
"description": "NetDDE Exporter Failed to Start.",
"sourceHierarchy": "Device",
"entered": "2018-06-28T21:59:46.734",
"exited": null,
"sourceType": "Not Transient",
"customerId": "08b00700-1326-4e60-bdf8-3016f0f4d588",
"groupId": "EIDEVA_2",
"activity": "Active"
}
}
]
}