You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
947 B
30 lines
947 B
import json |
|
import os |
|
import requests |
|
|
|
def read_json_file(file_path): |
|
try: |
|
with open(file_path, 'r', encoding='utf-8') as file: |
|
data = json.load(file) |
|
|
|
if isinstance(data, list): |
|
cnt = 0 |
|
for index, item in enumerate(data, start=1): |
|
url = "http://127.0.0.1:8443/api/v1/nodes-config" |
|
response = requests.post(url, data=json.dumps(item, ensure_ascii=False, indent=4), verify=False) |
|
print(f"{index} - response: {response.text}") |
|
cnt += 1 |
|
if cnt >= 18: |
|
break |
|
|
|
else: |
|
print("no array") |
|
|
|
except FileNotFoundError: |
|
print(f"no file") |
|
except json.JSONDecodeError: |
|
print("not json") |
|
except Exception as e: |
|
print(f"error: {e}") |
|
|
|
read_json_file('mock_topo_config.json') |