#!/usr/bin/env python3 import requests import os.path import json from datetime import datetime URL = "http://10.97.160.25/sample" FILE = 'CommonStarling_100962.wav' files = { "file": (os.path.basename(FILE), open(FILE,'rb').read(), 'audio/wave', {'Content-length' : os.path.getsize(FILE)}), "description" : (None, json.dumps({'date' : datetime.now().isoformat(), 'device_id' : '123'}), "application/json") } r = requests.post(URL,files=files) print("Content: ", r.content) print("Headers:", r.headers) r.raise_for_status()