Unit4 Multivers .netAPI

If you want to synchronize certain products from multivers with another (online) application, you can choose to use Unit4 Multivers .net API or the Unit4 multivers webAPI to make sure you are able to use them with your license, contact your accountmanager first.

I chose to use the .netapi because we didn’t want our multivers server to be directly connected to the internet with the web API. that’s why unit4 would post product update data to the webapplication, and load specific product data from the webapplication to update unit4 as well.

A basic example for posting certain categories products from unit4 in xml to a webapplication:

using System;
using System.IO;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Csla;
using Csla.Core;
using System.Xml.Linq;
using UNIT4.Multivers.API.BL.Base.Lists;
using UNIT4.Multivers.API.BL.CRM;
using UNIT4.Multivers.API.BL.CRM.Edit;
using UNIT4.Multivers.API.BL.CRM.Lists;
using UNIT4.Multivers.API.BL.Logistics.Lists;
using UNIT4.Multivers.API.BL.Logistics.Info;
using UNIT4.Multivers.API.BL.Logistics.Edit;
using UNIT4.Multivers.API.BL.CRM.Info;
using UNIT4.Multivers.API;
using System.Security.Principal;
using log4net;

private ProductInfoList productList;

private void postProductdata() {
 bool result = login();

 if (result != true) {

 //load products from unit4

 //Send data to the web application from selected categories (comma delimeted category ids 01,02 etc..)
 string categoryIds = ConfigurationManager.AppSettings["categoryIds"];

 List < string > categoryIds = categoryIds.Split(',').ToList();
 string applicationUrl = ConfigurationManager.AppSettings["applicationUrl"];

 XDocument xml = new XDocument();
 XElement productXmlList = new XElement("products");
 int postProductCount = 0;

 //Add all products within certain category id to the xml
 foreach(var prod in productList.Where(p => categoryIds.Contains(p.ProductGroupId) && p.TechnicalStock > 0)) {

  productXmlList.Add(new XElement("product",
   new XAttribute("productCode", prod.ProductId),
   new XAttribute("category", prod.ProductGroupId.ToString()),
   new XAttribute("description", prod.Description),
   new XAttribute("price", prod.PriceExclVat),
   new XAttribute("stock", prod.TechnicalStock),
   new XAttribute("SKU", ""),
   new XAttribute("EAN", prod.EANCode),


 if (postProductCount > 0) {
  xml.Add(new XElement("root", productXmlList));
  postXMLData(applicationUrl, xml.ToString());

private bool login() {

 string username = ConfigurationManager.AppSettings["unit4Username"];
 string password = ConfigurationManager.AppSettings["unit4Password"];
 string administrationName = ConfigurationManager.AppSettings["unit4Administration"];

 if (SessionContext.Login(username, password)) {
  if (SessionContext.OpenAdministration(administrationName)) {
   return true;
  } else {
   return false;

 } else {
  return false;

 * Load unit 4 products
private void getProductList() {
 productList = ProductInfoList.Fetch();





Leave a Reply

Your email address will not be published.