Uniconta’s API lets you programmatically inject any element values into an OIOUBL invoice/credit note and then send it via NemHandel—beyond the built-in tags available in the Uniconta client.
Namespace & Class
Namespace: Uniconta.API.DebtorCreditor
Class: NHRAPI
Constructors
You can initialise NHRAPI either with another API object or directly with a session and a company.
Generate Validated OIOUBL XML
Task<string> GetValidatedeDeliveryMappingDoc(DebtorInvoiceClient invoice, Dictionary<string,string> xmlPathAndValue)
Generates an OIOUBL document (as XML string) for the given invoice or credit note, inserting your custom values at the specified XML paths. The server validates the document before returning it.
Parameters
invoice: ADebtorInvoiceClientfor the target document.xmlPathAndValue: Dictionary where key = XML element path, value = element text.
When supplying keys in xmlPathAndValue, use ‘/’-separator for element paths.
Do not include the document root (Invoice or CreditNote) or Namespaces (cac: and cbc:).
So given this XML fragment:
Return
stringOIOUBL XML.
Error
If returned null, call
{NHRAPI object}.LastError
Send OIOUBL XML
Task<ErrorCodes> SendOIOUBL(string xml)
Sends a OIOUBL XML document via NemHandel.
Parameters
xml: The OIOUBL XML to send (for example, the output fromGetValidatedeDeliveryMappingDoc).
Return
ErrorCodesindicating the result of the send operation.
Error
{return result} != ErrorCodes.Succes
Full Example
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Uniconta.API.DebtorCreditor; // NHRAPI
using Uniconta.API.Service; // Session
using Uniconta.API.System; // CrudAPI
using Uniconta.ClientTools.DataModel; // DebtorInvoiceClient
using Uniconta.Common; // ErrorCodes
using Uniconta.DataModel; // Company
class Program
{
static async Task Main(string[] args)
{
// 1) Create session, and get company (not included in example)
Session session = null; // TODO: implement
Company company = null; // TODO: implement
// 2) Create API object
var api = new NHRAPI(session, company);
// 3) Define your XML path/value pairs
var xmlPathAndValue = new Dictionary<string, string>
{
["Note"] = "Thank you for your business",
["InvoiceLine/Note"] = "Handle with care",
["AccountingSupplierParty/Party/PostalAddress/Country/IdentificationCode"] = "DK",
["PaymentTerms/Note"] = "Net 14 days",
["OrderReference/ID"] = "PO-2025-0916"
};
// 4) Get a invoice ({filter} to be defined by you)
var invoice = (await new CrudAPI(api).Query<DebtorInvoiceClient>(/*filter}*/)).FirstOrDefault();
if (invoice == null)
{
Console.Error.WriteLine("Invoice not found.");
return;
}
// 5) Generate the OIOUBL XML with your mappings
string xml = await api.GetValidatedeDeliveryMappingDoc(invoice, xmlPathAndValue);
// 6) Check if generation failed
if (xml == null)
{
Console.Error.WriteLine($"GetValidatedeDeliveryMappingDoc failed: {api.LastError}");
return;
}
// 7) Send via NemHandel
ErrorCodes result = await api.SendOIOUBL(xml);
// 8) Check the result
if (result == ErrorCodes.Succes)
Console.WriteLine("OIOUBL document sent successfully via NemHandel.");
else
Console.Error.WriteLine($"SendOIOUBL failed with: {result}");
}
}