SAP OData Service URL Builder
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.
Fill in
Collection request
GET https://s4app.example.com:44300/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder?sap-client=100&$filter=SoldToParty%20eq%20%271000123%27&$select=SalesOrder,SoldToParty,TotalNetAmount,TransactionCurrency&$expand=to_Item&$orderby=CreationDate%20desc&$top=50&$format=json Accept: application/json Authorization: Basic <base64 of user:password>
Service metadata (check entity and field names first)
GET https://s4app.example.com:44300/sap/opu/odata/sap/API_SALES_ORDER_SRV/$metadata?sap-client=100 Accept: application/xml
Count only
GET https://s4app.example.com:44300/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder/$count?sap-client=100&$filter=SoldToParty%20eq%20%271000123%27
Modifying calls need a CSRF token
GET https://s4app.example.com:44300/sap/opu/odata/sap/API_SALES_ORDER_SRV/?sap-client=100 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.
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.
Need a safe read-only SAP query layer?
Ask how a private assistant could generate and run OData reads for your SAP team with approval controls.
Optional. The tool and every export work without this. No spam.
How to use the builder
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
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.
- 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
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
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.
Frequently Asked Questions
What is the standard URL format for an SAP OData service?
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?
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?
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?
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.
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.
Related Tools
SAP API Business Hub Request Generator
Build a ready-to-run cURL or HTTP request for an SAP API Business Hub sandbox or your own S/4HANA Cloud tenant, with the right headers and query options.
SAPSAP RFC Destination Setup Checklist (SM59)
Work through every step of creating and securing an RFC destination in SM59, from connection type to authorization and testing.
SAPSAP CPI iFlow Design Template
A fill-in design document for an SAP Cloud Integration iFlow, covering adapters, mappings, exception handling and monitoring, ready to hand to reviewers.
SAPSAP IDoc Message Types Reference (ORDERS, DESADV, INVOIC, MATMAS, DEBMAS)
Searchable list of common SAP IDoc message types with the basic IDoc type, business meaning and the X12 or EDIFACT message they usually map to.