C_CPI Integration Suite Development Practice Question
An integration developer is troubleshooting a failed message processing in SAP Cloud Integration. The integration flow uses a Groovy script to set a property named 'customerId' from the message body. The script throws a NullPointerException when the body is empty. The developer wants to ensure that the property is set to a default value if the body is empty, without causing the flow to fail. Which approach should be used in the Groovy script?
⚠ Common exam trap
The trap here is thinking that a try-catch block alone solves the problem, but it does not set a default value, leaving the property unset and causing downstream issues.
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
✓
Use the message.getBody(String.class) method and check for null before assigning.
The Groovy script should explicitly check if the message body is null before attempting to extract the customer ID. Using message.getBody(String.class) returns null for an empty body, allowing the script to assign a default value. This prevents the NullPointerException and ensures the property is always set, maintaining flow stability.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use the message.getBody(InputStream.class) method and read the stream without null checks.
Why it's wrong here
Reading the stream without null checks would still result in a NullPointerException if the body is empty, because the InputStream would be null. This approach does not handle the empty body scenario and would cause the flow to fail. It is not a robust solution for the requirement.
- ✗
Configure a Content Modifier step before the script to set a default body if empty.
Why it's wrong here
A Content Modifier step cannot conditionally set a default body based on emptiness without complex expressions. While it can set a body, it does not easily check for null. This approach adds unnecessary complexity and may not reliably handle the empty body case, making it less suitable than handling it directly in the script.
- ✗
Wrap the property assignment in a try-catch block and ignore the exception.
Why it's wrong here
Wrapping in try-catch and ignoring the exception would prevent the flow from failing, but it would not set the property to a default value. The property would remain unset, potentially causing downstream errors. This approach does not meet the requirement of ensuring a default value is assigned when the body is empty.
- ✓
Use the message.getBody(String.class) method and check for null before assigning.
Why this is correct
Using message.getBody(String.class) and checking for null allows the script to handle an empty body gracefully. If the body is null, the script can assign a default value to the property, preventing the NullPointerException. This approach ensures the integration flow continues without failure, which is the desired outcome.
About these practice questions
One of 218 original C_CPI practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.