Automating Statement-Import using Naiad Library

Hi, me again.

after upgrading Tryton 7.8 to 8.0.3 our automated Statement Import ( Using proteus to automate import of bank statement based on proteus) fail by receiving a 405 from the Backend.

In knowledge of the new Naiad Library (thanks to the Relase Notes), we decided, to migrate the Import.

On calling a wizard i’am getting stuck - also asking AI does not really help.

May I show my Code to you?

#!/usr/bin/env python

# -*- coding: utf-8 -*-

import base64
from naiad import Client, Record
import os
import io
import sys

try:

# Get Configuration
url = os.environ.get('TRYTON_URL', '')
apikey = os.environ.get('TRYTON_APIKEY', '')

# Connecting to Backend
client = Client(url, apikey)


# Read bank statement file (e.g., OFX, CAMT, MT940)
with open(sys.argv[1], "rb") as f:
    file_content = f.read()
encoded_file = base64.b64encode(file_content).decode('utf-8')


statement_import = Record('account.statement.import')
statement_import.file_ = encoded_file
statement_import.file_format = 'camt_052_001' # common formats: 'ofx', 'camt', 'mt940'


# Save the record profile to the server
statement_import = client.store(statement_import)


# Call the processing action on that stored record
# This bypasses the UI wizard and runs the exact backend execution method
client.action(statement_import, 'import_')

print("Import successful!")

except:
raise

On “client.action” Backend responds with an “503 Service unavailable”

Traceback (most recent call last):
  File "/srv/epro/erp/automation.prod.bank_stmt_import/automated.import_statement.camt-052.py", line 37, in <module>
    statement_import = client.store(statement_import)
  File "/srv/epro/erp/automation.prod.bank_stmt_import/venv/lib/python3.13/site-packages/naiad/__init__.py", line 229, in store
    return self.create(
           ~~~~~~~~~~~^
        record._model, record.to_values(), fields=fields)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/epro/erp/automation.prod.bank_stmt_import/venv/lib/python3.13/site-packages/naiad/__init__.py", line 169, in create
    response, content = self._request(
                        ~~~~~~~~~~~~~^
        'POST', f'/model/{model}',
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        params=params,
        ^^^^^^^^^^^^^^
        content=content)
        ^^^^^^^^^^^^^^^^
  File "/srv/epro/erp/automation.prod.bank_stmt_import/venv/lib/python3.13/site-packages/naiad/__init__.py", line 71, in _request
    response.raise_for_status()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/srv/epro/erp/automation.prod.bank_stmt_import/venv/lib/python3.13/site-packages/httpx/_models.py", line 829, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Server error '503 Service Unavailable' for url 'http://127.0.0.1:8321/epro_try_production//rest/model/account.statement.import'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503

Not getting helpfull Information out of the Logs (or doing wrong).

Does somebody have usefull hints to get my goal?

I am off now for a week - so please do not wonder, if I react late.

Thank you for your work!
Christian