ERPClimb logoERPClimb
OData V4
RAP / CDS / ODataintermediate 7 min read

OData V4 Part 2: Publishing a RAP Service with an OData V4 Binding

Preview · a free account unlocks the full lesson

Key takeaway

Publish a RAP service with an OData V4 binding end to end: create and publish the binding, understand the URL and versions, get a CSRF token, and run first read and write calls from a REST client.

In this lessonShow sections

Visual overview

OData V4 Part 2: Publishing a RAP Service with an OData V4 Binding — learning sheetFlow: Create and publish ZUI_PURCHREQ_O4 → Copy the URL; GET $metadata in the browser → In a REST client: fetch CSRF token, create a request (code example), read it back → Try the same POST without token → 403; add token → 201. Key ideas: CREATE AND PUBLISH THE BINDING; URL ANATOMY; SERVICE VERSIONS; FIRST CALLS FROM A REST CLIENT. Watch out: 403 on POST is usually a missing CSRF token, not missing authorization.ERPClimb.com / RAP / LESSON 2/6 / LEARNING SHEETOData V4 Part 2: Publishing a RAP Service with an OData V4Binding1 · HOW IT FLOWS1Create andpublishZUI_PURCHREQ_O42Copy the URL;GET $metadata inthe browser3In a RESTclientfetch CSRF token, createa request (code…4Try the samePOST withouttoken → 403; add…2 · KEY IDEAS EXPLAINEDCreate And Publish The BindingRight-click the service definition ZUI_PURCHREQ →New Service Binding.Name ZUI_PURCHREQ_O4, binding type "OData V4– UI".URL Anatomy/sap/opu/odata4 — OData V4 handlerzui_purchreq_o4 — binding (lower case)Service VersionsA V4 binding can contain several versions (0001,0002) based on different service definitions. Usea new version for breaking changes (Service…First Calls From A REST ClientGET the service root with basic authentication oryour SSO setup.For writes, first GET with header"X-CSRF-Token: Fetch"; the responsereturns a token and a session cookie.3 · REMEMBER · WATCH OUTRememberBinding type decides the consumer: OData V4 – UI (Fiori) or OData V4 –Web API (integrations).Activate + Publish is required; the binding shows the service URL.Every write request needs a CSRF token (fetched with a GET) — exceptin some API setups with other protection.!Watch out403 on POST is usually a missingCSRF token, not missingauthorization.4 · IN A REAL PROJECTAn integration developer reported "403 Forbidden" for every POST to a new RAP service and requestedmore authorizations. The basis team added roles twice without effect. GET requests worked fine. The responsebody actually said "CSRF token validation failed". The client never fetched a token. After adding…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Part 1 explained the contract. Now comes the part where the service actually gets made available and called — Service Bindings Part 2 covers the binding object in ADT in more depth, while this lesson focuses on the OData V4 side and the first calls against it.

Creating and publishing the binding starts by right-clicking the service definition ZUI_PURCHREQ and choosing New Service Binding, naming it ZUI_PURCHREQ_O4 with binding type "OData V4 – UI". After activating it, clicking Publish makes it available — on-premise this publishes the service locally, while in cloud systems publishing is part of the binding's own lifecycle. The binding then shows the service URL, the service versions, and the entity sets, each with a Preview button.

The URL itself breaks down into clear pieces: in /sap/opu/odata4/sap/zui_purchreq_o4/srvd/sap/zui_purchreq/0001/, /sap/opu/odata4 is the OData V4 handler, zui_purchreq_o4 is the binding name in lower case, srvd is the UI binding path segment (Web API bindings use srvd_a2x instead), and zui_purchreq/0001 names the service definition and its version.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.