import json from urllib import request, error data = json.dumps({ "frame_id": 1, "engine": "base_model", "threshold": 0.35, "iou_threshold": 0.8, "min_box_frac": 0.0, "target_class_names": [] }).encode('utf-8') req = request.Request('http://127.0.0.1:8000/api/batches/1/preview', data=data, headers={'Content-Type': 'application/json'}) try: with request.urlopen(req) as response: print(response.read().decode('utf-8')) except error.HTTPError as e: print(f"HTTPError: {e.code}") print(e.read().decode('utf-8')) except Exception as e: print(f"Error: {e}")