web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Trouble with HTTP call...
Power Automate
Answered

Trouble with HTTP call and parsing JSON

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi, everyone.

 

I am not very skilled with JSON. My flow sends an HTTP call (that works), then I parse the JSON (that works), then I have an Apply to Each where I use Features to loop and set different variables (the apply to each works, but the expression in one of my variables does not), then I parse JSON again (that doesn't work).

 

The Expression in my Set Variable

This works: 

if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-CO'), 'Colorado', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-TX'), 'Texas'))
But when I stack it up to include more states, it doesn't work:
if(equals(items('Apply to each 2')?['attributes']?['POOState'], 'US-CO'), 'Colorado', if(equals(items('Apply to each 2')?['attributes']?['POOState'], 'US-TX'), 'Texas', if(equals(items('Apply to each 2')?['attributes']?['POOState'], 'US-MN'), 'Minnesota', if(equals(items('Apply to each 2')?['attributes']?['POOState'], 'US-WI'), 'Wisconsin', if(equals(items('Apply to each 2')?['attributes']?['POOState'], 'US-MI'), 'Michigan', if(equals(items('Apply to each 2')?['attributes']?['POOState'], 'US-ND'), 'North Dakota', if(equals(items('Apply to each 2')?['attributes']?['POOState'], 'US-SD'), 'South Dakota', if(equals(items('Apply to each 2')?['attributes']?['POOState'], 'US-NM'), 'New Mexico'))))))))
The error says "Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The repetition action(s) 'Apply to each 2' referenced by 'inputs' in action 'Set_State_variable' are not defined in the template.'.'."
What am I doing wrong in the expression?
 
The Parse JSON Error
The 2nd parse JSON action doesn't work, either. I get an error that says "Unable to process template language expressions in action 'Parse_JSON_2' inputs at line '0' and column '0': 'Required property 'content' expects a value but got null. Path ''.'."
Here is my flow:
parse json 1.PNG
 
Then right after that I parse JSON again:
parse json 2.PNG
 
What do I have to do differently in the 2nd Parse JSON action? I really don't know what I'm doing wrong.
Categories:
I have the same question (0)
  • wskinnermctc Profile Picture
    6,519 Moderator on at

    In your expression example under 

    This works:

    if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-CO'),'Colorado',if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-TX'), 'Texas'))

     

    But when I stack it up to include more states, it doesn't work:
    if(equals(items('Apply to each 2')?['attributes']?['POOState'], 'US-CO'), 'Co.....................

     

    Did you stop putting the underscore _ between Apply_to_each_2?

     

    The underscore _ needs to be in the expression for spaces in a step title that is being referenced.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yup. That's what I did. I added the underscores back in and ran it, then got this error:

     

    Unable to process template language expressions in action 'Set_State_variable' inputs at line '0' and column '0': 'The template language function 'if' expects three parameter: the condition to test as the first parameter, the value to return if the condition is true as the second parameter, and the value to return if the condition is false as the third parameter. The function was invoked with '2' parameter(s). Please see https://aka.ms/logicexpressions#if for usage details.'.

     

    The flow successfully ran through 2 loops, then threw this error on the 3rd loop. The first Parse JSON action had logic in it to make it work should there be a null value, so I'm not sure why the error.

  • Verified answer
    wskinnermctc Profile Picture
    6,519 Moderator on at

    Can you copy and paste your full if() expression exactly as you have it in your flow? One of the if statements is incorrect or doesn't have a final option.

     

    I'm guessing it is the last if() statement for New Mexico needs a false output. So if it isn't 'US-NM' then what? You'll have to add a comma after 'New Mexico' and put a final option like 'Unknown' or some text.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    No way! Here it is:

     

    if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-CO'), 'Colorado', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-TX'), 'Texas', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-MN'), 'Minnesota', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-WI'), 'Wisconsin', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-MI'), 'Michigan', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-ND'), 'North Dakota', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-SD'), 'South Dakota', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-NM'), 'New Mexico'))))))))

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Yes, that is correct. It needed a final option, so this is what I put:

     

    if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-CO'), 'Colorado', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-TX'), 'Texas', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-MN'), 'Minnesota', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-WI'), 'Wisconsin', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-MI'), 'Michigan', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-ND'), 'North Dakota', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-SD'), 'South Dakota', if(equals(items('Apply_to_each_2')?['attributes']?['POOState'], 'US-NM'), 'New Mexico', 'false'))))))))

     

    Thank you!

     

    Now we're back to the 2nd JSON action not working. It ran through the loop perfectly, but gave me this error:

     

    InvalidTemplate. Unable to process template language expressions in action 'Parse_JSON_2' inputs at line '0' and column '0': 'Required property 'content' expects a value but got null. Path ''.'.

     

    The JSON in the first action has some failsafes built into it so that it will run should a value be null:

     

    },
    "CreatedBySystem": {
    "type": [
    "string",
    "null"
    ]
    },
    "IncidentSize": {
    "type": [
    "number",
    "null"
    ]

     

    Not being familiar with JSON, I am unsure what is supposed to go in the 2nd action.

  • wskinnermctc Profile Picture
    6,519 Moderator on at

    So the source of "Parse JSON 2" is the variable named "varFeatures"

     

    Where in your flow is the variable "varFeatures" getting populated?

    And what is the source of "varFeatures" being populated by?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Aha! It isn't getting set! It needs to get set in the Apply to Each 2 loop. When I try to add it, it creates another loop where it uses Layers:

     

    parse json 3.PNG

     

    When I try to run it, I get this error:

     

    ExpressionEvaluationFailed. The execution of template action 'Apply_to_each_3' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['body']?['layers']' is of type 'Null'. The result must be a valid array.

     

    I don't know why the flow insists on throwing another loop within the loop, but it's tried using a Layers loop before. Somehow my manager got the flow to stop doing that and the Apply to Each 2 loop was able to work as it should. I've tried everything to get the flow to stop adding the loop with Layers, but I can't seem to get around it. Also, the varFeatures variable is a string, if that matters.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    It turns out we did not need the second parse JSON action. Because we were able to filter the query in the first parse JSON action, we didn't need the second. That's what was stumping me.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 286

#2
David_MA Profile Picture

David_MA 256 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard