Perform Null Check in Logic App

Yet another issue that was very hard to solve and hard to test. I was performing an Http call that either returned a success, a failure or a time-out. In case of a time-out I had to do a retry by abandoning the servicebus message. In case of a regular error I had to send a message to the deadletter queue. The first thing I found out, is that the time-out didn’t result in an actual time-out, but in a bad request with an error description shown in the run history, but without a message body.

First, I tried to check if outputs(‘Http’)[‘body’] equals null. An error was returned that the expression could not be evaluated because property body could not be selected. In other words, I wasn’t able to perform a null check.

In the end, I didn’t find a way to directly test against null or undefined but I found a workaround using coalesce (return string value ‘NotExist’ if null). This is what the expression looks like.

"expression": {
"or": [
                  "equals": [
                              "@coalesce(body('HTTP'), 'NotExist')",