from requests import Request, Session import hashlib import string import random s = Session() def id_generator(size=6, chars=string.ascii_lowercase + string.digits): return ''.join(random.choice(chars) for _ in range(size)) def test(): data = { 'models': { 1: { 'id': 'model_' + id_generator(16), 'name': id_generator(16), 'url': id_generator(16), 'year_from': 1999, 'year_to': 2008, 'brand_id': 'brand_rbmjh7flxc9zgr0r', 'picture_id': 'picture_75g36ayxk9yvl8lz', }, 2: { 'id': 'model_' + id_generator(16), 'name': id_generator(16), 'url': id_generator(16), 'year_from': 1999, 'year_to': 2008, 'brand_id': 'brand_rbmjh7flxc9zgr0r', 'picture_id': 'picture_75g36ayxk9yvl8lz', }, 3: { 'id': 'model_' + id_generator(16), 'name': id_generator(16), 'url': id_generator(16), 'year_from': 1999, 'year_to': 2008, 'brand_id': 'brand_rbmjh7flxc9zgr0r', 'picture_id': 'picture_75g36ayxk9yvl8lz', }, } } req = Request('POST', 'https://new2.spavto96.ru/api/v1.0/show-case/batch-models', json=data, auth=('qwe', 'qwe')) prepped = req.prepare() resp = s.send(prepped) print(resp.status_code) print(resp.json()) test()