Skip to content

AI translation

This page was translated from German with AI. If in doubt, the German original applies.

Attachments, incoming documents and identifiers

Uploading attachments, taking incoming documents over into the inventory and reading the account’s own identifiers.

Attachments

var response = await client.DiwassApi.AttachmentApi.SubmitAttachment(
    content:             pdfBytes,
    typeId:              AttachmentTypeId.FacilityPermit,
    mimeCode:            "application/pdf",
    filename:            "genehmigung.pdf",
    containsPersonalData: false,
    context:             ZedalCallContext.Default.WithTimeout(600));

The overload with a pre-filled AttachmentBinaryObjectType still exists; for new code, the typed form is preferable. Reading is done via GetAttachment(attachmentIdentifier).

Always set the deadline for attachments yourself

Uploads and downloads don’t fit into the 30 seconds of the client default. Set WithTimeout(...) generously, or use WithoutDeadline() plus a CancellationToken to hand timing over to your code entirely.

The returned identifier is not necessarily the DiWaSS identifier

SubmitAttachment can return a provisional identifier of the form ZEDAL_TMP_ATT_ID_…. If a document with this identifier is sent to DiWaSS, DiWaSS rejects it with ATTACHMENT-NOT-FOUND — the attachment does not exist there under this identifier.

A central DiWaSS attachment identifier has the form <digits>ATT. Check the identifier before you write it into a document, and treat a ZEDAL_TMP_ATT_ID_ prefix as “not yet centrally registered” rather than as success. More error codes: Error codes.

Importing incoming documents

client.DocumentHandler.CreateInboxImporter() returns an IInboxImporter with ImportAsTransportAsync(...), ImportToFileAreaAsync(...), and ListPendingAsync(...). The importer reads the inbox via QueryApi.ListInboxDocuments with removed = false, filters on the server via doc.document_type, works page by page (pageSize, default 200), and returns an InboxImportReport whose Failed list names the entries that could not be imported. By default, only successfully imported entries are removed from the inbox; for unattended runs, there is removeOnFailure: true. The changes sample shows a complete run for notifications and movements.

Why this step is not optional and what a sound synchronization cycle looks like is described under Calls and synchronization — including the Commission’s rule to fetch only what is new and changed instead of a full export.

Incoming documents without the importer

If you want to control the steps yourself, call the same operations directly: list with removed = false, take over, read, remove. For a company’s movements, it looks like this:

var pending = await client.CoreApi.Query.ListInboxDocuments(new QueryParameter
{
    Filter =
    {
        new FilterCondition { Path = "removed", Op = Operator.Equal, Operands = { new Variant { B = false } } },
        new FilterCondition { Path = "doc.document_type", Op = Operator.Equal, Operands = { new Variant { S = "VB" } } },
    },
    Sort = { new Sort { Path = "doc.last_changed", Direction = SortDirection.Asc } },
    PageSize = 100,
});

foreach (var entry in pending.Entries)
{
    var inboxDocId = entry.Doc.DocumentId;
    var docId = await client.CoreApi.Documents.ImportTransportDocumentFromInbox(inboxDocId);

    var movement = client.DocumentHandler.CreateMovementHandler();
    await movement.LoadFromZedal(docId);
    // … process the movement

    await client.CoreApi.Documents.RemoveDocumentsFromInbox(new[] { inboxDocId });
}
  • The identifier of the incoming entry (entry.Doc.DocumentId) is not the identifier in the inventory. Reading, processing and saving use the docId from the import.
  • Notifications are taken over into the file area with ImportDocumentToFileAreaFromInbox(inboxDocId, minPrivacyLevel) and loaded with CreateNotificationHandler().
  • Remove an entry only after it has been processed successfully. An entry that remains comes back in the next run.
  • If there are more incoming entries than PageSize, query again after processing. The entries taken over are then removed; only those that remained are at the front. PageStart counts from 1; behind n remaining entries, the next page starts at n + 1.

Your own identifiers — MyAccount

var operatorIds = await client.MyAccount.GetOwnDiwassOperatorIds();
// IReadOnlyList<long> — DiWaSS OperatorInternalIds of this account

var bmuNumbers = await client.MyAccount.GetOwnBmuZksNumbers();
// IReadOnlyList<string> — BMU ZKS numbers (national, not numeric)

MyAccount is a facade over client.CoreApi.AccountManager.GetAccountNumbers() and filters the assigned numbers by type. You need the DiWaSS operator IDs as OperatorInternalId on the DiWaSS documents. Numbers that cannot be read as long are silently skipped by GetOwnDiwassOperatorIds() — so an empty list means “no matching number assigned”, not “error”.