Dibk.Oppsamlingsregister.IngestApi.Client 1.0.17

dotnet add package Dibk.Oppsamlingsregister.IngestApi.Client --version 1.0.17
                    
NuGet\Install-Package Dibk.Oppsamlingsregister.IngestApi.Client -Version 1.0.17
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dibk.Oppsamlingsregister.IngestApi.Client" Version="1.0.17" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dibk.Oppsamlingsregister.IngestApi.Client" Version="1.0.17" />
                    
Directory.Packages.props
<PackageReference Include="Dibk.Oppsamlingsregister.IngestApi.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dibk.Oppsamlingsregister.IngestApi.Client --version 1.0.17
                    
#r "nuget: Dibk.Oppsamlingsregister.IngestApi.Client, 1.0.17"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Dibk.Oppsamlingsregister.IngestApi.Client@1.0.17
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dibk.Oppsamlingsregister.IngestApi.Client&version=1.0.17
                    
Install as a Cake Addin
#tool nuget:?package=Dibk.Oppsamlingsregister.IngestApi.Client&version=1.0.17
                    
Install as a Cake Tool

Dibk.Oppsamlingsregister.IngestApi.Client

A lightweight .NET client for sending batches to the Oppsamlingsregisteret Ingest API. It is designed for use with IHttpClientFactory, handles multi-file uploads (multipart/form-data), and provides resilient retries with exponential backoff + jitter. Authentication/authorization is expected to be handled by the Azure resource itself (for example RBAC on the managed identity or by exposing the API only inside a private VNet), so the client does not attach tokens or API keys.

Contents


Installation

dotnet add package Dibk.Oppsamlingsregister.IngestApi.Client

Target frameworks

  • .NET 8.0
  • .NET 10.0

Quickstart

Via appsettings.json

OppsamlingsregisterIngestApiOptions can be bound directly from configuration. The DI extension registers an HttpClient, binds the options, and sets sensible defaults (BaseAddress, Accept: application/json, Timeout).

{
  "OppsamlingsregisterIngestApiOptions": {
    "BaseUrl": "https://ingest.example.com",
    "RetryCount": 3,
    "RetryBaseDelayMs": 250
  }
}
// Program.cs
builder.Services.AddOppsamlingsregisterIngestApiClient(builder.Configuration);
// IOppsamlingsregisterIngestApiClient can now be injected

Programmatic configuration

You can also configure the client without appsettings by passing an Action<OppsamlingsregisterIngestApiOptions>.

builder.Services.AddOppsamlingsregisterIngestApiClient(opts =>
{
    opts.BaseUrl = "https://ingest.example.com";
    opts.RetryCount = 3;
    opts.RetryBaseDelayMs = 250;
});

Usage

IOppsamlingsregisterIngestApiClient exposes SendBatchAsync to submit a batch of files. The client builds a multipart/form-data request containing metadata (archiveReference, distributionSubmittalType, sentAtUtc) alongside every file in the IngestRequest.

using Dibk.Oppsamlingsregister.IngestApi.Client;
using Dibk.Oppsamlingsregister.IngestApi.Client.Models;

public class MyService(IOppsamlingsregisterIngestApiClient client)
{
    public async Task RunAsync(CancellationToken ct)
    {
        var request = new IngestRequest
        {
            ArchiveReference = "ar-2025-09-08-001",
            DistributionSubmittalType = "demo",
            Files = new[]
            {
                new IngestFilePart
                {
                    FileName = "data.xml",
                    ContentType = "application/xml",
                    Metadata = new Dictionary<string, string>
                    {
                        ["source"] = "client-demo",
                        ["note"] = "optional"
                    },
                    OpenReadAsync = _ => Task.FromResult<Stream>(File.OpenRead("data.xml"))
                },
                new IngestFilePart
                {
                    FileName = "map.gml",
                    ContentType = "application/gml+xml",
                    OpenReadAsync = _ => Task.FromResult<Stream>(File.OpenRead("map.gml"))
                }
            }
        };

        await client.SendBatchAsync(request, ct);
    }
}

IngestFilePart.OpenReadAsync must return a new stream for every attempt (retries included), therefore it is a Func<CancellationToken, Task<Stream>>. Add per-file metadata using the Metadata dictionary when needed.


Configuration options

All settings live on OppsamlingsregisterIngestApiOptions:

Field Type Default Description
BaseUrl string Base URL of the ingest API (no trailing slash).
RetryCount int 3 Number of retries for transient failures (HTTP 5xx/408/connection issues).
RetryBaseDelayMs int 250 Base delay (ms) for exponential backoff with jitter.

Error handling

  • Transient failures (HTTP 5xx/408, network/timeout exceptions) trigger exponential backoff with jitter. The number of attempts is controlled by RetryCount.
  • Non-transient failures (or when the retry budget is exhausted) throw IngestApiException with the HTTP status and any raw response payload as text.
  • On success the API is expected to return 204 No Content, so SendBatchAsync simply completes.

Publishing to NuGet

Tag a release:

git tag ingest-client_1.2.3
git push origin ingest-client_1.2.3

Notes

  • Authentication: access control should be enforced at the Azure resource (e.g. RBAC on the managed identity or private endpoints inside a VNet). The client intentionally omits auth headers/tokens.
  • Models: see IOppsamlingsregisterIngestApiClient, IngestFilePart, and IngestRequest for the payload structure.
  • DI registration: use AddOppsamlingsregisterIngestApiClient(...) with either the IConfiguration or Action<OppsamlingsregisterIngestApiOptions> overload.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.17 332 1/21/2026
1.0.15 94 1/20/2026
1.0.14 270 11/28/2025
1.0.13 139 11/28/2025
1.0.12 187 11/27/2025
1.0.11 369 11/21/2025
1.0.10 557 11/19/2025
1.0.9 406 11/19/2025
1.0.8 446 11/18/2025
1.0.7 396 11/18/2025
1.0.6 403 11/18/2025
1.0.5 339 11/17/2025
1.0.4 236 11/14/2025
1.0.3 260 11/14/2025
1.0.2 284 11/13/2025
1.0.1 198 9/9/2025
1.0.0 177 9/9/2025
0.0.1 183 9/9/2025