Hi,
We're having a problem with the way Outsystems works with the default values.
We have some optionals values and fields that may need to be sent depending on other fields and values.
The problem we're having is that if we set to True the field "Send default value", Outsystems will send always the field with the default value, event if we don't want to send it. So it will return back to us an schema error, because that field is unexpected.
But if we set to False the field "Send default value", we're having a trouble too. That's because sometimes we need to send the field with a False or default value and Outsystems will not send it, so a validation schema error will appear again, because is expecting that field in this case.
Is there any way to change the behavior about sending the default values while consuming an integration?
We may show you and explain you the problem in a call if you want.
Regards
Hello Ruli,
As you already wrote, you unfortunately have to decide on an option regarding the handling of default values. However, it is possible to manipulate the REST request before sending and the REST response after receiving. OutSystems offers the two events OnBeforeRequest and OnAfterResponse for this purpose.
Depending on how complex the required JSON manipulations are, it may be advisable to use the JSONata Forge component. For more details, please check out this article by Stefan Weber.
Hope this helps, Sebastian
Hi Ruli,
With booleans it's a real problem, since those can only have one of two values. So no, you cannot easily force both values and still leave them out sometimes.
With other values, you can choose a default value that's outside the bounds of normal communication. For example, you can set a default value of "***THIS IS THE DEFAULT***" for a Text field, so it isn't sent if you do not explicitly set it, or set a value of 999999999 for an Integer, assuming that's also not something you'd normally send.
Otherwise you indeed need to manipulate the JSON sent in an OnBeforeRequest, as Sebastian suggested. I don't think you'd ever need the OnAfterResponse, as OutSystems has no schema validation on REST JSON, so whatever is sent is ok (as long as valid values for the data types are used).