SAP Business One integration: Integration Framework (B1i), Service Layer, DI API and connectors
sap business one integration framework
Also searched as
- sap business one saas integration
- sap business one api documentation
- sap b1 service layer vs di api
- sap b1i
Short answer
Business One offers four main ways to integrate: the Service Layer (REST/OData, the default for new work), the Integration Framework B1i (scenario based middleware), the DI API (COM/.NET, for legacy and add-ons) and third party or SaaS connectors. Pick the Service Layer for new web integrations and B1i when you want packaged scenarios and message flows.
Applies to: SAP Business One 10.0 (SQL Server and HANA). Service Layer endpoint path and version differ by release.
Choose and set up an integration approach
- 1List the integration needs: direction (in, out, both), volume, latency, who owns the other system, and whether you need transformation or only calls.
- 2For REST based integrations, use the Service Layer. Log in with a POST to /b1s/v1/Login with CompanyDB, UserName and Password, then reuse the B1SESSION cookie for requests.
- 3For scenario based flows with transformation, monitoring and packaged content, use the Integration Framework (B1i) and its scenario packages.
- 4For in-process add-ons or older systems on Windows, use the DI API (and UI API for screens).
- 5For SaaS apps such as e-commerce, CRM or banking, check for an existing certified connector before building your own.
- 6Secure the integration: dedicated API user with minimal authorizations, TLS, secrets in a vault and logging of calls.
- 7Test with production-like volume and handle session timeouts, retries and idempotency.
Comparing the options
Service Layer: web service on the Business One server exposing business objects as OData REST resources with JSON. It is stateful with a session, supports batch requests, queries with $filter and $select, and user-defined objects. It is the recommended route for new external integrations and for custom web apps. The API documentation is on the SAP Help Portal and the service exposes its metadata at the service root.
DI API: a COM/.NET library installed on a Windows machine that connects to the company database. It is mature and rich, used by many add-ons, but couples you to Windows and to the client version. Integration Framework (B1i): a middleware engine with scenario packages, message routing and transformation, and monitoring, good for connecting to other systems in a structured way, though more heavyweight than a direct API call.
POST https://b1server:50000/b1s/v1/Login
{ "CompanyDB": "SBODEMO", "UserName": "api_user", "Password": "***" }GET /b1s/v1/Items?$select=ItemCode,ItemName&$filter=ItemCode eq 'A100'
SaaS and cloud integration
For cloud applications, the usual patterns are a certified connector from a partner, an iPaaS platform calling the Service Layer, or a small middleware you host. If your Business One runs on-prem behind a firewall, expose the Service Layer through a reverse proxy or VPN with authentication, rather than opening it directly to the internet.
Plan for the session model: Service Layer sessions time out and a worker pool should re-login and retry safely. Keep calls idempotent where you can, for example by storing an external reference in a user-defined field and checking before creating a document.
When AI joins the picture
AI assistants need the same things any integration does: authenticated, least-privilege access and an audit trail. Read paths can use the Service Layer or a read-only database user, and write paths should go through the Service Layer with approval by a person, so the standard validation applies.
A private deployment keeps documents and master data inside your network while still letting users ask questions in plain language.
Try it here, free
SAP Business One DI API Sales Order Code Generator (C#)
Fill in connection and order details to get a C# DI API skeleton that connects, adds a sales order and reports errors.
Common pitfalls
- !Using the DI API from a web service on Linux or in a container where it is not supported.
- !Ignoring session timeouts so calls start failing in the middle of a batch.
- !Exposing the Service Layer port directly to the internet.
- !Using a super user for the integration account.
- !Updating tables directly because the API call felt slow.
How an ERP-grounded AI assistant handles this
For question answering over Business One, a read-only layer works against the Service Layer or a reporting replica, and writes are proposed and approved by a person before the Service Layer call. Netray builds this as an on-prem or private cloud deployment so the model and the data stay in your environment.
Frequently asked questions
What is the difference between B1i and the Service Layer?
The Service Layer is a REST/OData API for calling Business One objects directly. B1i is an integration middleware with scenario packages, message routing and transformation. Many projects use the Service Layer directly, and B1i when they want its packaged flows.
Is the DI API deprecated?
It remains available and widely used by add-ons, but for new external integrations SAP guidance favours the Service Layer. Check the current documentation for your version before you commit to the DI API.
Where is the SAP Business One API documentation?
On the SAP Help Portal under SAP Business One, which has the Service Layer API reference and the DI API reference, and on the SAP Business Accelerator Hub for sample content.
How do I avoid Service Layer session errors?
Reuse the session cookie, handle timeouts by logging in again and retrying, and keep a limited number of concurrent sessions per licence. Do not log in for every request.
Related
Fix SAP Business One Service Layer 'Invalid session' (code 301)
The Service Layer returns code 301 'Invalid session or session already timed out' when the B1SESSION cookie you send no longer maps to a live session. The usual causes are the default idle timeout (30 minutes), a missing or altered cookie, a load balancer sending the call to a different node because ROUTEID was dropped, or a restarted Service Layer. Fix it by keeping cookies on every call and re-logging in once on a 301.
How-toSAP Business One tables list: the core tables and how the names work
SAP Business One table names follow a pattern: O plus a short object name for header tables (OITM items, OCRD partners, ORDR sales orders), the same letters with a 1 for row tables (RDR1), and U_ prefixed columns or @ prefixed tables for user-defined objects. Read them for reports, but write only through the DI API or Service Layer.
How-toHow to Use BAPI_TRANSACTION_COMMIT Correctly
SAP's BAPI programming model separates business logic from the database commit on purpose, so a caller must explicitly call BAPI_TRANSACTION_COMMIT after a successful BAPI - usually with WAIT = 'X' - or the created object never actually persists. Skipping this step, or forgetting WAIT, is the most common reason a BAPI 'runs fine' but nothing gets saved.
Error fixSAP M7 021: Deficit of SL Stock Quantity
M7 021 fires during a goods issue, delivery, or confirmation when SAP checks the unrestricted-use (SL) stock for the exact plant, storage location and batch combination and finds less than what you are trying to post out. Fix the entry (batch, storage location, quantity) first; only enable negative stock or downgrade the message to a warning if the business genuinely needs to post ahead of a receipt.
Error fixSAP IDoc Status 51: Application Document Not Posted
Status 51 tells you the IDoc reached the application layer and failed to post, but the status text itself is not the error - the real cause sits in the status record's long text or the linked application log. Fix the underlying data or configuration, then reprocess the IDoc through BD87 rather than editing the status.
Error fixSAP Short Dump TIME_OUT: Maximum Runtime Exceeded
A TIME_OUT runtime error means a dialog (or RFC) work process ran longer than the maximum allowed runtime, controlled by profile parameter rdisp/max_wprun_time (600 seconds by default). The fix is almost always to move the long-running work to background processing or tune the underlying program, not to raise the timeout.
AI for ERPAI for SAP Business One, Without Sending Your Books to a Public API
Add AI to SAP Business One without sending customer data or financials to a public API. Service Layer and DI API integration, sized for an SMB budget.
AI for ERPA Private LLM Grounded on Your ERP Data
How a private LLM answers questions on your ERP data: RAG plus text-to-SQL, role-based permissions inherited from the ERP, and where each fits.
Stuck on SAP Business One?
Talk to engineers who work inside SAP Business One every week, and who build private AI that answers these questions from your own ERP data.
Keep exploring
Free tools
- SAP Business One DI API Sales Order Code Generator (C#)Fill in connection and order details to get a C# DI API skeleton that connects, adds a sales order and reports errors.
- SAP B1 Service Layer Sales Order JSON GeneratorFill in server, company database, customer and line details to get ready-to-test Login and sales order POST requests for the Service Layer REST API.
- SAP Business One Service Layer Request BuilderFill in host, company and item details and get ready-to-paste Service Layer requests for login, item query, sales order and production order.
ERP fixes and how-tos
- Private AI for SAP Business One: Service Layer, a read replica and a local modelAdd a private AI assistant to SAP Business One: Service Layer reads, SQL Server or HANA replica, document index, local LLM, permissions and approvals.
- Fix SAP Business One Service Layer 'Invalid session' (code 301)Fix 'Invalid session or session already timed out' in the SAP Business One Service Layer: B1SESSION and ROUTEID cookies, timeout, relogin and pooling.
- SAP Business One production planning: MRP, production orders, cost and variancesSAP Business One production planning end to end: MRP, planned to released orders, cost rollup, variance reporting and when you need a manufacturing add-on.
Runs with your ERP
- SAP Field Service Management with SAP Business OneHow SAP Field Service Management, with Coresuite, syncs with SAP Business One service calls and billing: data flows, setup, pitfalls and a private AI layer.
- ECOSIRE CPQ Configurator with SAP Business One: guided quotingHow the ECOSIRE CPQ configurator uses option models, requires/excludes rules and live cost roll-up to create SAP Business One quotes and orders.
- Alumio and Magento with SAP Business OneHow Alumio links Adobe Commerce (Magento) to SAP Business One for orders, stock and products: data flows, setup, pitfalls and a private AI layer.
AI on your ERP
- AI for SAP Business One, Without Sending Your Books to a Public APIAdd AI to SAP Business One without sending customer data or financials to a public API. Service Layer and DI API integration, sized for an SMB budget.
- AI for SAP Business One Purchasing, From Purchase Request to A/P InvoiceGround AI in SAP Business One purchasing: purchase requests, POs, goods receipts and A/P invoices via Service Layer, read-only, on-prem or private cloud.
Integrations
- How to add AI agents to SAP Business OneHow to put AI agents on SAP Business One: Service Layer tool design, read-only first, draft documents for human approval, and an on-prem model option.
- How to use ChatGPT with SAP Business OneUsing ChatGPT with SAP Business One: exports versus live Service Layer access, custom GPT actions, enterprise data controls, and when a private model fits better.