I would like create a data action with an input contract which accepts null value.
My use case is the following : if the value is filled it gives a result if not , a result is given with a defaut value
In my example, I have made test with the input contract tAcw.
When I configued with no value, I get this error :
8. Execute: The request could not be understood by the server due to malformed syntax.
REST call for action execute failed. Message:Request to backend service failed. Response from web service: {"message":"Must populate at least one of the parameters [gt, gte, lt, lte]","code":"bad.request","status":400,"messageParams":{},"contextId":"1240ab46-0190-4225-ad1a-3ce2716a6237","details":[],"errors":[]} [ad5abbb0-c1fc-48fe-920c-6c345b916328]
I have configured the request body template with this code for the tAcw which should accept "null" value
{
"type": "metric",
"metric": "tAcw",
"range": {
"lte": "#if( {input.tAcw} ){input.tAcw}#else ${input.tAcw}=10#end" }
}
I have attached the export action for more details
There might be other ways to do this.
But I tried the following (Request Configuration - text below is when using Simple definition) and it seems to work.
thanks for your help
I have replaced by your suggestion int the Request Body Template, but now I get this error :
2. Validate draft definition: The request could not be understood by the server due to malformed syntax.
Action POST TEST NULL value failed validation. Errors: [Template validation failed for 'config.request.requestTemplate'. Details: Encountered "mydefault" at validate config.request.requestTemplate[line 55, column 20] Was expecting one of: ... "{" ... ]
It seems there is a problem with the variable mydefault, do you have made modification from my data Action sent?
I meant that there might be other ways that I don't know.
First time I tried a velocity if/else to replace a null value.
I did try (unsuccessful) to put the value directly after the else (without going through the mydefault variable).
I could make it work when the value was string with a to z characters.
But it didn't work with the integer value.
So instead of trying to figure out if this could be done that way, I preferred to use the variable and #set (which worked).