# SAP Business One Service Layer Request Builder

> Source: https://netray.co/tools/sap-business-one-service-layer-request-builder
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Fill in host, company and item details and get ready-to-paste Service Layer requests for login, item query, sales order and production order.

## Category

developer

## Erp

SAP Business One

## Audience

- B1 developer
- Integration engineer
- B1 consultant

## Tool

**Kind:** template

**Output:** code

**Language:** http

**Fields:**

#### Server host

**Key:** host

**Type:** text

**Default:** b1server.example.com

#### Service Layer port

**Key:** port

**Type:** text

**Default:** 50000

#### Company database

**Key:** company

**Type:** text

**Default:** SBODEMOUS

#### B1 user

**Key:** user

**Type:** text

**Default:** manager

#### Item code

**Key:** item

**Type:** text

**Default:** FG-1001

#### Customer code

**Key:** customer

**Type:** text

**Default:** C20000

#### Quantity

**Key:** qty

**Type:** number

**Default:** 25

#### Due date

**Key:** due

**Type:** date

**Default:** 2026-11-15

#### Warehouse code

**Key:** whs

**Type:** text

**Default:** 01

**Blocks:**

#### 1. Login (returns the B1SESSION cookie)

**Body:** POST https://{{host}}:{{port}}/b1s/v1/Login
Content-Type: application/json

{
  "CompanyDB": "{{company}}",
  "UserName": "{{user}}",
  "Password": "<password>"
}

#### 2. Read an item with selected fields

**Body:** GET https://{{host}}:{{port}}/b1s/v1/Items('{{item}}')?$select=ItemCode,ItemName,InventoryItem,ItemWarehouseInfoCollection
Cookie: B1SESSION=<session id from login>

#### 3. Find open sales orders of a customer

**Body:** GET https://{{host}}:{{port}}/b1s/v1/Orders?$select=DocEntry,DocNum,CardCode,DocDueDate,DocumentStatus&$filter=CardCode eq '{{customer}}' and DocumentStatus eq 'bost_Open'&$orderby=DocDueDate
Cookie: B1SESSION=<session id from login>

#### 4. Create a sales order

**Body:** POST https://{{host}}:{{port}}/b1s/v1/Orders
Content-Type: application/json
Cookie: B1SESSION=<session id from login>

{
  "CardCode": "{{customer}}",
  "DocDueDate": "{{due}}",
  "DocumentLines": [
    {
      "ItemCode": "{{item}}",
      "Quantity": {{qty}},
      "WarehouseCode": "{{whs}}"
    }
  ]
}

#### 5. Create a production order

**Body:** POST https://{{host}}:{{port}}/b1s/v1/ProductionOrders
Content-Type: application/json
Cookie: B1SESSION=<session id from login>

{
  "ItemNo": "{{item}}",
  "PlannedQuantity": {{qty}},
  "DueDate": "{{due}}",
  "Warehouse": "{{whs}}",
  "ProductionOrderType": "bopotStandard"
}

#### 6. Logout

**Body:** POST https://{{host}}:{{port}}/b1s/v1/Logout
Cookie: B1SESSION=<session id from login>

**Notes:** Entity and property names follow the Service Layer metadata (check /b1s/v1/$metadata on your server) and vary slightly by version. Port 50000 is the common default. Use a dedicated integration user and never paste real passwords into shared files.

## Content

**Intro:** The Service Layer is the REST and OData interface of SAP Business One, running as the b1s service on top of the database. This builder writes the usual requests so you can paste them into Postman, curl or an HTTP client.

**Sections:**

#### How the session works

**Body:** You call Login once with the company database, user and password. The response sets a B1SESSION cookie, which every later request must send. Sessions time out after a period of inactivity, so long-running integrations should catch a 401 and log in again. Always call Logout when a batch finishes, because each session holds a licence slot.

**Bullets:**

- Login once per batch, reuse the cookie
- Handle session timeout by re-login
- Logout frees the licence
- Use $metadata to confirm entity names

#### Querying with OData options

**Body:** Use $select to return only the fields you need, $filter for conditions, $orderby for sorting and $top or $skip for paging. The server returns pages and a next link when the result is large, so a loop must follow that link rather than assuming one response. Filter strings use eq, ne, gt, and and or, with text values in single quotes.

#### Creating documents safely

**Body:** A POST to Orders or ProductionOrders runs the same validations as the client, so required fields, series and approval procedures apply. Test in a copy of the database first. Expect errors for closed periods, frozen items and missing warehouses, and log the response body, since it carries the B1 error code and message.

**Cta:** Building an integration between Business One and your shop floor, portal or AI agents? Netray can help design it with human approval on any write-back.

**Faq:**

#### What is the default Service Layer port?

**Answer:** Commonly 50000 for the Service Layer on HANA and SQL Server installations, served over HTTPS. Your administrator may have changed it or placed a load balancer in front, so confirm the actual URL with the server team.

#### Does the Service Layer use my B1 license?

**Answer:** Yes. Each session logged in as a B1 user consumes a license of the type assigned to that user, so use a dedicated integration user and log out when the work is done.

#### How do I page through large results?

**Answer:** Use $top and $skip, or follow the odata.nextLink the server returns. The server applies its own maximum page size, so do not assume that all rows arrive in one response.

#### Can I call the Service Layer from a browser?

**Answer:** Technically yes, but it needs CORS configuration and exposes credentials. Calls normally go from a backend service that holds the credentials and applies its own access rules.

## Search terms

sap business one service layer, sap b1 service layer examples, b1s v1 login, sap b1 service layer create sales order, sap b1 service layer production order, sap b1 rest api, sap business one odata, service layer postman

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
