Forum Discussion
janemckinney
Apr 25, 2022Copper Contributor
Getting null return value when data exists
Getting the following error: The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['body']?['value']' is of type 'Null...
janemckinney
Apr 25, 2022Copper Contributor
Got it solved.
When using the flow editor, adding a "set variable" step automatically wraps the action in an "apply to each" step, using body('Parse JSON')?['body']?['value'] as the output to use. Using the expression editor to change this to body('Parse JSON')?['value'] solves this problem. Example screen shots below.
Requiring the author to make this change feels like a bug, as it defeats the purpose of using a no-code tool.
Looking at some other related posts, it may be a result of the JSON having an array named "value" within the "body." If so...it's definitely a bug.
Fails (which is the default):
Works:
- samb2180Sep 15, 2023Brass ContributorSame here... makes no sense at all, as it's intented to avoid coding. Did you find a workaround?
Thank you! - lamama2Jan 13, 2023Copper Contributor
janemckinney THANK YOU. This was such a mystery, and your clear instructions helped me solve the same problem.