def post_data_to_endpoint(host, endpoint, headers, data): url = f"{host}/{endpoint}" response = requests.post(url, headers=headers, data=json.dumps(data)) if response.status_code == 200: return response.json() else: return f"Error: {response.status_code}" # Replace with your actual host, endpoint, headers and data host = "http://172.24.52.8" endpoint = "accor_modeling" headers = {"Host": "ds-idm-prod.sb.se.com"} data_path = './cannot_predict_testing.json' with open(data_path, 'r') as f: data = json.load(f) print(post_data_to_endpoint(host, endpoint, headers, data))
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter