Skip to content

ChuanGz/sap-b1-service-layer

SAP B1 Service Layer

SAP B1 Service Layer is a C# client library for the SAP Business One Service Layer. The repository wraps SAP Business One REST and OData endpoints behind adapter-based resource clients so consuming applications can use a more consistent API shape across documents, business partners, inventory operations, and master data.

Highlights

  • Adapter-based client model for SAP Business One resources
  • Shared IB1Client interface for common CRUD-style operations
  • Coverage for business partners, items, orders, invoices, credit notes, warehouses, and stock movements
  • .NET 8 class library with no external host application required

Repository Layout

  • Sap.B1ServiceLayer: main class library
  • Sap.B1ServiceLayer/Adapters: adapter classes that expose a common client shape
  • Sap.B1ServiceLayer/Services: resource-specific endpoint implementations
  • Sap.B1ServiceLayer/System: shared helpers, configuration types, and low-level support code
  • docs: architecture and resource coverage notes

Supported Resources

  • business partners
  • business places
  • items
  • sales orders
  • purchase orders
  • invoices
  • credit notes
  • sales people
  • warehouses
  • unit of measurement
  • stock entries
  • stock exits
  • stock transfers
  • stock transfer requests

Quick Start

Build

dotnet build sap-service-layer.sln

Reference the Library

dotnet add <your-app>.csproj reference Sap.B1ServiceLayer/Sap.B1ServiceLayer.csproj

Basic Usage

using Sap.B1Client.Adapters;
using Sap.B1Client.System;
using Sap.B1Client.System.Interfaces;

var options = SAPHelper.BuildB1Option(
    "https://your-service-layer-host:50000",
    "CompanyDB",
    "UserName",
    "Password"
);

IB1Client client = new B1CreditNoteAdapter(options);
var response = client.Retrieve("123");

Usage Model

  • Services know the SAP Business One endpoint path and operation details for a specific resource.
  • Adapters expose those resource-specific operations through the shared IB1Client interface.
  • Consumers configure options once, choose the adapter that matches the target resource, and issue requests through a stable interface.

Limitations

  • The library does not provide a public login or session lifecycle API.
  • Request payloads are mostly passed as object, so consumers are responsible for shaping document payloads correctly.
  • The library does not include a sample application, CLI, or integration test project.
  • Namespaces such as Sap.B1Client still reflect legacy naming and were intentionally left unchanged to avoid breaking consumers.

Session Handling Note

Requests rely on a cookie header managed by the underlying client base. The codebase contains protected login behavior, but it is not surfaced as a public session management API. Consumers are expected to manage session cookies themselves or extend the adapter layer when they need first-class login support.

Tech Stack

  • C#
  • .NET 8
  • RestSharp
  • Newtonsoft.Json
  • Microsoft.Extensions.Options

Naming Review

The repository name now reflects SAP Business One more explicitly. A few public API names inside the library are still older or less expressive than they could be, for example:

  • SAPHelper.BuildB1Option
  • requiredTemplate
  • changeContent

These names can be improved later, but changing them now would create avoidable breaking changes in the public API.

Additional Docs

References

Usage Policy

  • This repository is shared for learning, technical review, and knowledge sharing.
  • No permission is granted to copy, reuse, modify, redistribute, sublicense, sell, deploy, or use this code in another repository, product, service, or internal system without prior written approval from the repository owner.
  • See LICENSE, NOTICE.md, DISCLAIMER.md, CONTRIBUTING.md, and CODE_OF_CONDUCT.md.

About

C# client library for SAP Business One Service Layer with adapter-based resource clients.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages