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

OData V4 Part 3: Test CRUD Requests, Payloads and Responses

Preview · a free account unlocks the full lesson

Key takeaway

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 sections

Visual overview

OData V4 Part 3: Test CRUD Requests, Payloads and Responses — learning sheetIn one line: 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.ERPClimb.com / RAP / LESSON 3/6 / LEARNING SHEETOData V4 Part 3: Test CRUD Requests, Payloads andResponses1 · IN ONE LINETest 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.2 · KEY IDEAS EXPLAINEDStart With Metadataentity-set names;key fields;Read An Entity SetA basic GET request can look conceptually like:Use Query Options Carefully$select$filterRead One Entity By KeyThe exact key syntax depends on the entity key andEDM type.3 · DO · AVOIDBest practice!Common mistakeTreat metadata as the API contract.Test read and write paths separately.Keep business rules in RAP, not in the servicebinding.✕Guessing service paths.✕Ignoring metadata.✕Updating without concurrency control.4 · IN A REAL PROJECTA Fiori app shows a generic “request failed” message when a user saves a Travel. The team initiallyinvestigates the frontend. API testing shows the POST request reaches the backend and RAP returns adate-validation error because EndDate is before BeginDate. The service is working correctly. The improvement…Original ERPClimb learning sheet • Verify against your SAP release and edition

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.

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.