指定のカラムにPDFファイルを登録したいです

実現したいこと

kintoneにPDFを登録したいです。

pythonで下記のように実装しましたがエラーが出ていました、サーバーエラーが出力されます。

エラーメッセージ

Response Status Code: 520
Response Text: {"code":"GAIA_IC01","id":"Z4yZJpJKxx3Z0HaRelSk","message":"Content-Typeを指定してください。"}
requests.exceptions.HTTPError: 520 Server Error: 520 for url: https://xxxxx.cybozu.com/k/v1/file.json

実行したコード

import csv
import requests
import os

BASE_URL = 'https://xxxx.cybozu.com'
API_TOKEN = 'xxxxxx'
APP_ID = '1'
ATTACHMENT_FIELD_CODE = 'ATTACHED_FILE'

def upload_attachment_to_kintone(APPY_ID, attachment_file_path):
    query = f'APPY_ID = "{APPY_ID}"'
    resp = requests.get(
        f'{BASE_URL}/k/v1/records.json',
        params={
            'app': APP_ID,
            'query': query
        },
        headers={
            'X-Cybozu-API-Token': API_TOKEN,
        }
    )
    resp.raise_for_status()
    records = resp.json().get('records') 
    if records:
        record_id = records[0]['$id']['value']
        with open(attachment_file_path, 'rb') as f:
            files = {'file': (os.path.basename(attachment_file_path), f)}
            file_resp = requests.post(
                f'{BASE_URL}/k/v1/file.json',
                headers={
                    'X-Cybozu-API-Token': API_TOKEN,
                },
                files=files
            )
            file_resp.raise_for_status()
            file_key = file_resp.json()['fileKey']

            payload = {
                'app': APP_ID,
                'id': record_id,
                'record': {
                    ATTACHMENT_FIELD_CODE: {
                        'value': [
                            {
                                'fileKey': file_key,
                                'name': os.path.basename(attachment_file_path)
                            }
                        ]
                    }
                }
            }
            update_resp = requests.put(
                f'{BASE_URL}/k/v1/record.json',
                json=payload,
                headers={
                    'X-Cybozu-API-Token': API_TOKEN,
                }
            )
            update_resp.raise_for_status()
    else:

FIELD_MAPPING = {
    'APPY_ID': 'APPY_ID',
    'ATTACHED_FILE': 'ATTACHED_FILE'
}

with open('123.csv', 'r', encoding='shift-jis', errors='ignore') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        try:
            APPY_ID = row[FIELD_MAPPING['APPY_ID']]
            attachment_filename = row[FIELD_MAPPING['ATTACHED_FILE']]

            attachment_file_path = f'attachments/{attachment_filename}'
            if not attachment_filename:
                print(f'添付ファイルがありません')
            else:
                upload_attachment_to_kintone(CASE_ID, attachment_file_path)

        except requests.HTTPError as e:
            print(f'Response Status Code: {e.response.status_code}')
            print(f'Response Text: {e.response.text}')
            raise
        except Exception as e:
             print(f'Error: {e}')

Content-Typeを指定してください。のエラー出ますが指定すると以下のエラーが出力されます

Response Text: {"code":"GAIA_HM02","id":"C1g6nvSFqKzljXdtpR4Q","message":"アップロードするHTTPリクエストの形式が正しくありません。HTTPリクエストはマルチパート形式である必要があります
。"}

自己解決しました。