# SAP OData Service URL Builder

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

## Short answer

Generate a correct SAP Gateway OData V2 request URL with query options, test it in a browser or REST client, then reuse it in your code.

## Category

sap

## Erp

SAP S/4HANA / SAP Gateway

## Audience

- SAP Fiori developer
- SAP integration developer
- SAP Gateway administrator

## Tool

**Kind:** template

**Output:** code

**Language:** http

**Fields:**

#### Host name

**Key:** host

**Type:** text

**Default:** s4app.example.com

#### HTTPS port

**Key:** port

**Type:** text

**Default:** 44300

#### SAP client (sap-client)

**Key:** client

**Type:** text

**Default:** 100

#### Service path

**Key:** service

**Type:** text

**Default:** /sap/opu/odata/sap/API_SALES_ORDER_SRV

#### Entity set

**Key:** entity

**Type:** text

**Default:** A_SalesOrder

#### $filter (URL encoded)

**Key:** filter

**Type:** text

**Default:** SoldToParty%20eq%20%271000123%27

#### $select fields

**Key:** select

**Type:** text

**Default:** SalesOrder,SoldToParty,TotalNetAmount,TransactionCurrency

#### $expand navigation

**Key:** expand

**Type:** text

**Default:** to_Item

#### $orderby

**Key:** orderby

**Type:** text

**Default:** CreationDate%20desc

#### $top

**Key:** top

**Type:** number

**Default:** 50

#### Format

**Key:** format

**Type:** select

**Options:**

- json
- xml

**Default:** json

**Blocks:**

#### Collection request

**Body:** GET https://{{host}}:{{port}}{{service}}/{{entity}}?sap-client={{client}}&$filter={{filter}}&$select={{select}}&$expand={{expand}}&$orderby={{orderby}}&$top={{top}}&$format={{format}}
Accept: application/json
Authorization: Basic <base64 of user:password>

#### Service metadata (check entity and field names first)

**Body:** GET https://{{host}}:{{port}}{{service}}/$metadata?sap-client={{client}}
Accept: application/xml

#### Count only

**Body:** GET https://{{host}}:{{port}}{{service}}/{{entity}}/$count?sap-client={{client}}&$filter={{filter}}

#### Modifying calls need a CSRF token

**Body:** GET https://{{host}}:{{port}}{{service}}/?sap-client={{client}}
X-CSRF-Token: Fetch

Then send the token returned in the response header X-CSRF-Token on POST, PATCH or DELETE, with the same session cookie.

**Notes:** This builds OData V2 style URLs as used by SAP Gateway and the S/4HANA released APIs. Service names, entity sets and field names differ by release, so read $metadata first. Spaces and quotes must be URL encoded. Never hard code real credentials, and activate the service in /IWFND/MAINT_SERVICE before calling it.

## Content

**Intro:** SAP OData services follow a strict URL pattern, and a missing quote or an unencoded space is the usual reason a call returns 400. This builder assembles the host, service, entity set and system query options into a clean request you can paste into a REST client.

**Sections:**

#### How to use the builder

**Body:** Fill the host, port and client, then the service path and the entity set. Add only the query options you need. The output includes the collection request, the $metadata call, a $count call and the CSRF fetch pattern. Copy the first block into Postman or a browser, and check names against $metadata before you code.

#### The query options that matter

**Body:** SAP Gateway V2 supports $filter, $select, $expand, $orderby, $top, $skip, $count and $format. String values in a filter need single quotes, for example SoldToParty eq '1000123', and key properties in an entity URL need the same. Not every property is filterable, which the metadata marks with sap:filterable.

**Bullets:**

- Use $select to cut payload size on wide entities
- Page with $top and $skip, and sort with $orderby for stable pages
- $expand only navigation properties listed in the metadata
- Use sap-client to target a client on ABAP based systems

#### Authentication and write calls

**Body:** Read calls can use basic authentication on a test system, but production normally uses OAuth or SAML through your gateway or BTP. Any change call needs a CSRF token fetched with X-CSRF-Token: Fetch, and the same session cookie must be reused. A 403 on a POST usually means the token was missing or expired.

#### Common mistakes

**Body:** Calling a service that is not activated in /IWFND/MAINT_SERVICE returns 404. Forgetting URL encoding of the filter returns 400. Requesting thousands of rows without $top can time out the dialog work process, so always page.

**Cta:** If you want natural language questions to turn into safe OData reads against your SAP system, Netray builds read-only ERP assistants that show the query they run.

**Faq:**

#### What is the standard URL format for an SAP OData service?

**Answer:** The usual format is https://host:port/sap/opu/odata/sap/SERVICE_NAME/EntitySet, with optional query options after a question mark. Custom services may live under /sap/opu/odata/ with a namespace instead of /sap.

#### How do I write a filter with a string value?

**Answer:** Wrap the value in single quotes and URL encode the spaces, for example $filter=SoldToParty%20eq%20%271000123%27. Combine conditions with and or or. Dates use datetime'2026-01-01T00:00:00' in V2 services.

#### Why do I get a 404 on a service that exists?

**Answer:** The service is probably not activated or registered on the front end server. Check /IWFND/MAINT_SERVICE, add the service, and verify the ICF node is active in SICF. Also confirm the system alias points to the right backend.

#### Does this work for OData V4?

**Answer:** The URL structure is similar, but V4 uses paths under /sap/opu/odata4 and slightly different syntax, for example $filter values without the datetime prefix. Use this builder as a base and adjust the service path and literals.

## Search terms

sap odata url, sap odata filter example, sap gateway odata service url, sap odata $expand, api_sales_order_srv url, sap odata query builder, /sap/opu/odata/sap, sap odata $top $skip

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