C_CPI Integration Suite Development Practice Question
An integration developer is building an integration flow that uses a Groovy script to modify the message body. The script must access a header named 'CustomerID' and set it as a property named 'CustID' for later use in the flow. Which code snippet correctly accomplishes this in SAP Cloud Integration?
⚠ Common exam trap
The trap here is assuming that headers and properties are interchangeable or that the method 'getHeader' exists, when in fact they serve different purposes and only 'getHeaders().get()' is valid.
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 custId = message.getHeaders().get("CustomerID"); message.setProperty("CustID", custId);
The correct Groovy snippet must read the header 'CustomerID' using the appropriate API and then set an exchange property 'CustID'. The 'message' object in SAP Cloud Integration provides 'getHeaders().get()' for headers and 'setProperty()' for properties. Using 'getHeader' or reading from properties would fail, and setting a header instead of a property would not meet the requirement. Thus, the snippet that uses 'getHeaders().get()' and 'setProperty()' is correct.
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 custId = message.getHeaders().get("CustomerID"); message.setHeader("CustID", custId);
Why it's wrong here
This snippet correctly retrieves the header 'CustomerID' but then sets a new header 'CustID' instead of a property. The requirement is to set a property named 'CustID'. While setting a header might work in some contexts, it does not fulfill the specific need to create a property for later use within the flow, and could interfere with header propagation.
- ✗
def custId = message.getProperties().get("CustomerID"); message.setProperty("CustID", custId);
Why it's wrong here
This snippet attempts to retrieve 'CustomerID' from properties, but the requirement is to read a header. Properties and headers are distinct in SAP Cloud Integration; headers are typically used for transport-level metadata, while properties are for flow-level variables. Using 'getProperties().get("CustomerID")' would return null if the value is only in a header, leading to incorrect behavior.
- ✗
def custId = message.getHeader("CustomerID"); message.setProperty("CustID", custId);
Why it's wrong here
The method 'getHeader' does not exist on the message object in SAP Cloud Integration Groovy scripts. The correct method is 'getHeaders().get()' or 'getHeader(name)' is not available. Using 'getHeader' would cause a compilation error or runtime exception. Therefore, this snippet is incorrect and would not retrieve the header value.
- ✓
def custId = message.getHeaders().get("CustomerID"); message.setProperty("CustID", custId);
Why this is correct
In SAP Cloud Integration Groovy scripts, the 'message' object provides methods to access headers and set properties. 'getHeaders().get("CustomerID")' retrieves the header value, and 'setProperty("CustID", custId)' sets an exchange property. This is the correct API for the scenario, ensuring the header value is stored as a property for subsequent steps.
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.