Share via

Logic app condition issue

Nicolas Mikellides (CTC ITEC) 20 Reputation points
Aug 11, 2023, 7:04 AM

Hello,

I have a logic app where i call HTTP GET with filter. Now whenever the body returns "value": [] as if no results are available after filtering i create a condition where the Team is created. E.g if body of HTTP GET has no value (meaning true) go ahead and create a team . In my condition i have if (HTTP GET output body) contains ("value":[]) then its true for some reason it always resolves to false no matter the output of the GET.Is there some other way to tackle this?

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,448 questions
{count} votes

Accepted answer
  1. Mike Urnun 9,856 Reputation points Microsoft Employee
    Aug 16, 2023, 5:20 PM

    Hello, @Nicolas Mikellides (CTC ITEC) - Thanks for reaching out!

    In order to use the Conditional effectively, it's important to determine what kind of data types we are working with. In your case, it looks like the response data should be surrounded by curly braces, {}, like below:

    {
    	"value":[]
    }
    

    This is something that you should address first and make sure there are curly braces. That way, we can safely assume that the response is going to be a valid JSON object where its value property is expected to be data type of an Array. Because we know that arrays are a data type that holds collection of items, we can leverage that fact in our Conditional such that it checks if the Array is either empty (has 0 items) or has one or more items in it, like below:
    User's image

    The above the correct & ideal approach for you to implement the Conditional. However, If for some reason the surrounding braces aren't going to be there in the response for it to be a valid JSON object, we should then safely assume that the response is going to be a data type of String like the below:

    "value:[]"
    

    In the case of String data type, we can use the contains operator per your original approach but have the double-quotes wrap the entire String value, like below:User's image

    I have tested both of the approaches above & confirmed that they work as expected. Could you try these approaches and let me know if the issue gets resolved? In case you run into any other issues or need further clarity, just let me know!

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Nicolas Mikellides (CTC ITEC) 20 Reputation points
    Aug 11, 2023, 7:10 AM

    input

    Output1

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.