Отправка xml файла post запросом на python используя токен авторизации

Отправка xml файла через postman проходит, следовательно сервер работает и принимает данные. Пытаюсь реализовать отправку файла через python,токен автоизации получаю, а вот на запрос отправки xml выдает ошибку 500.

with open('keys.json', mode='r') as file:
    key = json.load(file)

url_autorizations = key['url_autorizations']
url_send_passport = key['url_send_passport']

client_id = key['client_id']
client_secret = key['client_secret']
grant_type = key['grant_type']

# Данные для запроса Авторизации
data = {
    'client_id': client_id,
    'client_secret': client_secret,
    'grant_type': grant_type
}

# Запрос получения токена
access_token_requests = requests.post(url_autorizations, data=data)
response = access_token_requests.json()
access_token = response['access_token']   
data_headers = {
    'Authorization': f'Bearer {access_token}',
    'Content-Type': 'multipart/form-data'
}
# Отпрака файла XML
files = {}
with open('send_file.xml', 'rb') as xml_file:
    files['file'] = xml_file
    file_requests = requests.post(url_send_passport, files=files, headers=data_headers)

Ответы (1 шт):

Автор решения: Андрей

Пришел к такому решению https://requests.readthedocs.io/en/latest/user/quickstart/#post-a-multipart-encoded-file

with open('keys.json', mode='r') as file:
    key = json.load(file)

url_autorizations = key['url_autorizations']
url_send_passport = key['url_send_passport']

client_id = key['client_id']
client_secret = key['client_secret']
grant_type = key['grant_type']

# Данные для запроса Авторизации
data = {
    'client_id': client_id,
    'client_secret': client_secret,
    'grant_type': grant_type
}

# Запрос получения токена
access_token_requests = requests.post(url_autorizations, data=data)
response = access_token_requests.json()
access_token = response['access_token']   
data_headers = {
    'Authorization': f'Bearer {access_token}',
}
# Отпрака файла XML
files = {'files': ('send_file.xml', open('send_file.xml', 'rb'), 'application/xml')}
response = requests.post(url_send_passport, files=files, headers=data_headers)
→ Ссылка