C_CPI Integration Suite Development Practice Question
An integration developer needs to create a script that reads a custom header named 'Country' from the incoming message and sets a property named 'CountryCode' based on a mapping. The script must be written in Groovy and run in SAP Cloud Integration. Which code snippet correctly retrieves the header and sets the property?
⚠ Common exam trap
The trap here is assuming that headers and properties can be accessed like Groovy maps or that method names are interchangeable, when the SAP Cloud Integration message API requires specific methods like getHeader and setProperty.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
def country = message.getHeader("Country"); message.setProperty("CountryCode", country);
The correct Groovy script must use the message object's getHeader method to read the 'Country' header and setProperty to create the 'CountryCode' property. The other options use incorrect method names, bracket notation that is not supported, or swap header and property operations. Only the snippet using getHeader and setProperty performs the required actions.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
def country = message.getProperty("Country"); message.setHeader("CountryCode", country);
Why it's wrong here
This snippet retrieves a property named 'Country' and sets a header named 'CountryCode', which is the opposite of what is required. The scenario specifies reading a header and setting a property, so this option reverses the roles and would not work as intended.
- ✗
def country = message.headers["Country"]; message.properties["CountryCode"] = country;
Why it's wrong here
While Groovy allows map-like access, the message object in SAP Cloud Integration does not expose headers and properties as maps directly. The correct API uses getHeader and setProperty methods. Using bracket notation may result in a MissingPropertyException or incorrect behavior.
- ✗
def country = message.getHeaders().get("Country"); message.setProperty("CountryCode", country);
Why it's wrong here
In Groovy scripts for SAP Cloud Integration, the message object is not directly available as 'message'; you must use the 'message' variable provided by the script context, but the methods are getHeader and setProperty on the message object. However, the correct method to retrieve a header is getHeader, not getHeaders().get(). Using getHeaders() returns a map, but the standard API uses getHeader.
- ✓
def country = message.getHeader("Country"); message.setProperty("CountryCode", country);
Why this is correct
This snippet uses the correct methods: getHeader to retrieve the header value and setProperty to set a property. In SAP Cloud Integration Groovy scripts, the message object provides getHeader and setProperty methods. This is the standard way to access and set message attributes within a script step.
About these practice questions
This C_CPI question is part of Courseiva's 218-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official SAP exam blueprint
This C_CPI practice question is part of Courseiva's free SAP certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C_CPI exam.