Developer ToolsFree generatorPDF, Excel, Word exportSAP Business One

SAP Business One Service Layer Sales Order Request Generator

The SAP Business One Service Layer exposes business objects such as sales orders as REST resources. Getting the first login and order request right is the usual hurdle for integration developers, so this tool generates both from your values.

Fill in

Generated code
Download:

1. Log in

POST https://b1server.example.com:50000/b1s/v1/Login
Content-Type: application/json

{
  "CompanyDB": "SBODEMOUS",
  "UserName": "api_user",
  "Password": "<your password>"
}

2. Create the sales order

POST https://b1server.example.com:50000/b1s/v1/Orders
Content-Type: application/json
Cookie: B1SESSION=<session id from login response>

{
  "CardCode": "C20000",
  "DocDueDate": "2026-11-15",
  "NumAtCard": "PO-77415",
  "DocumentLines": [
    {
      "ItemCode": "A00001",
      "Quantity": 10,
      "UnitPrice": 125.50
    },
    {
      "ItemCode": "A00002",
      "Quantity": 4
    }
  ]
}

3. Read it back

GET https://b1server.example.com:50000/b1s/v1/Orders?$filter=NumAtCard eq 'PO-77415'&$select=DocEntry,DocNum,CardCode,DocTotal
Cookie: B1SESSION=<session id>

Verify the base path, port and entity names for your version, since Service Layer paths and supported fields differ between releases. Line two omits UnitPrice so the system applies the price list. Never commit passwords. Log out with POST /b1s/v1/Logout when done and test in a non-production company first.

Integration review

Optional review of your Service Layer integration design, error handling and security.

Optional. The tool and every export work without this. No spam.

How to use it

Enter your Service Layer host and port, company database, user and the business data for the order. Copy the generated Login request, send it with any REST client, and take the session ID from the response. Then send the Orders request with that session cookie. The third block reads the order back by customer PO number.

How the API is shaped

Login returns a session ID that you send as the B1SESSION cookie. Documents are created by POST to their collection, such as Orders, with header fields at the top level and an array of DocumentLines. Field names follow the business object schema, for example CardCode, DocDueDate, ItemCode and Quantity. Queries use OData options like filter and select.

  • Sessions time out, so handle re-login on a 401
  • Omitting UnitPrice lets the price list apply
  • Use NumAtCard to store the customer's PO reference

Testing and safety

Create the order in a test company first, then check it in the client. Use a dedicated API user with limited authorisations. Keep passwords in a secret store, not in scripts. Record the returned DocEntry and DocNum in your integration log so you can trace each order back to its source.

Common mistakes

Forgetting the session cookie, sending numbers as strings, using a date format the server rejects, passing an inactive item or customer code, and posting duplicates after a timeout. Make integrations idempotent by checking NumAtCard before creating the order.

Frequently Asked Questions

What is the Service Layer?

It is the REST and OData based API of SAP Business One for HANA and SQL versions that lets external applications read and write business objects over HTTPS. Availability and details depend on your version.

Why does my POST return an authentication error?

Usually the session cookie is missing or expired. Log in again and send the B1SESSION value on every request. Also check the user has authorisation for the object.

How do I avoid duplicate orders?

Query by a unique reference such as NumAtCard before you post, and store the returned DocEntry. If a request times out, check for the order before retrying.

Can I create other documents the same way?

Yes. Deliveries, invoices, purchase orders and business partners follow the same pattern with their own collections and field names. Check the entity reference for your version.

If you want an integration between your e-commerce, EDI or shop floor and SAP Business One reviewed or built, Netray can help. The generator is free on its own.