35
Views
5
Comments
Web Developer Specialization – Sample Exam: Clarification on REST API Question

Hello everyone,

I’m reviewing a question from the Web Developer Specialization – Sample Exam related to a POST REST API integration. Some requests fail with the error:

“The PhoneNumber attribute must not be null.”

In this scenario, PhoneNumber is not mandatory in the app, but the external API does not accept null values.

The sample exam marks the correct answer as:

B. Set the Send Default Value property to Yes

However, I initially thought Option C (using the OnBeforeRequest callback to populate PhoneNumber when it’s missing) would be the better approach, as it allows conditional handling and avoids unnecessary logic.

I’m sharing the screenshot of the question for reference.

Could someone please explain:

  • Why Send Default Value = Yes is considered the correct answer in this exam?

  • How this prevents the API from receiving a null value?

  • When this approach is preferred over OnBeforeRequest?

Thanks in advance for your insights.




2025-12-19 11-44-03
Marvei Paña

Hi, if you set the Send Default Value to yes, instead of sending a null value if you are sending an empty phone number it will instead send a 0, which is not a null value. Therefore this won't trigger a request fail error

2025-12-22 13-50-43
Sherif El-Habibi
Champion

Hello,

When Send Default Value works, imagine you have a REST method with an input parameter like PhoneNumber in the question. This input has a default value set in its properties, for example 1234. If the frontend does not send this parameter or sends it with no value, OutSystems automatically uses the default value to avoid errors in case you set Send default value to true. This is very useful when the input is technically mandatory in the payload, but from a business perspective it isn’t, so it handles it for you.

Using OnBeforeRequest is not wrong actually, and you can implement logic there, such as checking if an input is null and then assigning a value like 1234. However, if your payload contains many attributes, say 50 inputs where 20 need the same handling, this approach requires more effort, more code, and increases the chance of errors. That’s why Send Default Value is the more accurate and cleaner solution, and why option B is the correct answer.


2023-10-16 05-50-48
Shingo Lam

I agree that you can handle the logic in OnBeforeRequest, but what is it for? is it business requirement or you presume that? I am also from high-code before moving here, and I need to change the mindset a lot to adapt the low-code concept

Outsystems is low-code with the utility to free us from coding as much as possible. Then, you try to spend more effort on the non-required steps instead of the clean supported solution. Does it make sense anymore?

Therefore, I vote for B to be the best solution in these 4 options

2019-01-07 16-04-16
Siya
 
MVP

@Mohammad Shad :  You may test this by creating a sample application and execute a REST end point against https://httpbin.org/anything ( a dummy service where you can test REST services)

Basically if you do not provide a value the payload will not contain that attribute at all

Eg : I have a request in the below  format.  

If I do not provide value in say PhoneNo my data that request send is 


And if your services is expecting PhoneNo this will throw exception at the receiving end.  So the solution is set Send Default Value to Yes.  Here is the output after you set Send Default Value = Yes

Here you can see that payload contains default value even if user did not provide the same.

2026-01-26 10-25-31
Lennart Kraak
Champion

Hello Mohammad,

I think the answers above are already quite clear.
Please also keep in mind that the OnBeforeRequest is an action / event handler on the level of the REST API, not the method. Therefore it would be executed for any method that you call in the API, forcing you to check which method is being called before setting your dummy phone number, making your code a lot less clear.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.