OData V4 Part 3: Test CRUD Requests, Payloads and Responses
Preview · a free account unlocks the full lesson
Test a RAP OData V4 service end to end with metadata, GET, POST, PATCH and DELETE requests, while understanding HTTP status codes, payloads and transaction behavior.
In this lessonShow sectionsHide sections
Visual overview
Explanation
In Part 2 you published a RAP service with an OData V4 service binding.
This lesson tests that service the way an API consumer would, covering how to read service metadata, identify entity sets and keys, send GET requests, create data with POST, update data with PATCH, delete data where the business object allows it, understand common HTTP responses, and separate OData problems from RAP behavior problems.
The examples here are illustrative — exact service URLs, key formats and draft behavior depend on the specific RAP model and SAP release. Before starting, you should already have an active RAP business object, a projection view, a service definition, an OData V4 service binding, and a published or previewable service endpoint.
Everything starts with metadata rather than business requests. Metadata is the contract: it defines entity-set names, key fields, property names and types, navigation properties, actions and functions, and annotations. It's important not to guess a field name from the CDS source when the public service exposes a different name — the service contract, not the CDS source, is what the client actually sees.
Reading an entity set is the simplest operation: conceptually, "GET /Travels" with an "Accept: application/json" header returns, on success, an HTTP 200 status and a JSON payload containing rows from the entity set. When the result looks wrong, work through the possibilities in order: is the service binding correct, is the right entity set being called, is authorization filtering the data, is the CDS or projection returning the expected rows, and is the client itself applying filters or query options.
OData V4 query options need to be used carefully. Commonly available options include $select, $filter, $orderby, $top, $skip and $expand — for example, "GET /Travels?$select=TravelID,CustomerID,Status&$top=20". $select should be used when the client only needs a small set of fields, and $filter should reduce data at the server rather than downloading everything and filtering client-side. $expand should only be used when the client genuinely needs related data, since large nested expansions can become expensive.
Reading one entity by key depends on the entity's key and EDM type, but conceptually looks like "GET /Travels(<key>)", with composite keys requiring all required key values to be supplied.
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
Interview questions on this topic
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.