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

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / error message with "sw...
Power Automate
Answered

error message with "switch" function

(1) ShareShare
ReportReport
Posted on by 24
I have a scheduled cloud flow that should run every 3 months. for each run I want to send a different e-mail.
 
with the compose function I create an number output value for the month (december = 12).
 
 
with the "switch" and "case" function , if the value equals 12 I send an e-mail. when I add those 2 functions and I try to save my flow, I always get this error message:
 
{"message":"Request failed with status code 400","name":"AxiosError","code":"ERR_BAD_REQUEST","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","accept-language":"en-US","x-ms-client-session-id":"3ec066f0-cb0f-11f0-9062-5fb206e6b131","x-ms-client-request-id":"45efeb9d-1bb0-4879-94ec-de872fc1f258","authorization":""},"operationName":"PROCESSSIMPLE:PATCH/PROVIDERS/MICROSOFT.PROCESSSIMPLE/ENVIRONMENTS/FLOWS/","params":{"api-version":"1","$expand":"properties.connectionreferences.apidefinition,properties.definitionsummary.operations.apioperation,operationDefinition,plan,properties.throttleData,properties.estimatedsuspensiondata,properties.licenseData,properties.billingContext,properties.throttlingBehavior,properties.powerFlowType,properties.protectionStatus","telemetryMetadata":"{\"modifiedSources\":\"Portal\"}"},"method":"patch","url":"https://5162741ef526e9639d6129318afedc.14.environment.api.powerplatform.com/powerautomate/flows/72524e5a-e99b-4a61-ba8f-d9e03463bbd8","data":"{\"properties\":{\"connectionReferences\":{\"shared_office365\":{\"id\":\"/providers/Microsoft.PowerApps/apis/shared_office365\",\"connectionName\":\"shared-office365-3711e7a8-9360-4dc3-91c7-a4993216f607\"}},\"definition\":{\"$schema\":\"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#\",\"contentVersion\":\"undefined\",\"parameters\":{\"$authentication\":{\"defaultValue\":{},\"type\":\"SecureObject\"},\"$connections\":{\"defaultValue\":{},\"type\":\"Object\"}},\"triggers\":{\"Recurrence\":{\"type\":\"Recurrence\",\"recurrence\":{\"frequency\":\"Minute\",\"interval\":\"2\",\"startTime\":\"2025-11-26T22:30:00.000Z\",\"timeZone\":\"Romance Standard Time\"}}},\"actions\":{\"Compose\":{\"type\":\"Compose\",\"inputs\":\"@formatDateTime(utcNow(), 'MM')\",\"runAfter\":{}},\"Switch\":{\"type\":\"Switch\",\"expression\":{},\"default\":{\"actions\":{}},\"cases\":{\"Case\":{\"actions\":{\"Send_an_email_(V2)\":{\"type\":\"OpenApiConnection\",\"inputs\":{\"parameters\":{\"emailMessage/To\":\"bart.willocx@organon.com\",\"emailMessage/Subject\":\"test 2\",\"emailMessage/Body\":\"<p class=\\\"editor-paragraph\\\">test 2</p>\",\"emailMessage/Importance\":\"Normal\"},\"host\":{\"apiId\":\"/providers/Microsoft.PowerApps/apis/shared_office365\",\"operationId\":\"SendEmailV2\",\"connectionName\":\"shared_office365\"}}}},\"case\":11}},\"runAfter\":{\"Compose\":[\"SUCCEEDED\"]}}}},\"displayName\":\"test 2\",\"environment\":{\"name\":\"5162741e-f526-e963-9d61-29318afedc14\"}},\"name\":\"72524e5a-e99b-4a61-ba8f-d9e03463bbd8\",\"telemetryMetadata\":{\"modifiedSources\":\"Portal\"}}","team":"PowerAutomate","bodyDetails":{"locale":"en-US"},"axios-retry":{"retryCount":0,"lastRequestTime":1764195477310},"context":{"ppapiContext":{"endpoint":"5162741ef526e9639d6129318afedc.14.environment.api.powerplatform.com"}},"knownServiceId":"ppapi-pauto","activityId":"84584db7-12b2-47e9-b1ae-e423ad9bb396"},"request":{},"response":{"data":{"error":{"code":"TemplateValidationError","message":"The power flow's logic app flow template was invalid.  The object expression '{}' at line '1' and column '761' of action 'Switch' has '0' top level properties. Only '1' is allowed."}},"status":400,"statusText":"","headers":{"access-control-allow-origin":"*","access-control-expose-headers":"Content-Type,Date,Server,Access-Control-Allow-Origin,Access-Control-Expose-Headers,Content-Length,x-ms-ppapigateway,x-ms-gateway-clusters,x-ms-request-id,x-ms-correlation-request-id,x-ms-flow-mobile-ios-version,x-ms-armresiliency,x-ms-flow-routing-request-id,Strict-Transport-Security","cache-control":"no-cache, no-store","content-length":"237","content-type":"application/json; charset=utf-8","date":"Wed, 26 Nov 2025 22:17:57 GMT","strict-transport-security":"max-age=31536000; includeSubDomains","x-ms-armresiliency":"False","x-ms-correlation-request-id":"af574a2c-1899-4393-a621-d4742d565ee3","x-ms-flow-mobile-ios-version":"3.0.421","x-ms-flow-routing-request-id":"EASTUS:20251126T221757Z:7d6bef2f-f726-4f81-bfc9-3b96483b4700","x-ms-gateway-clusters":"prdil102eus","x-ms-ppapigateway":"_prdil102eusgb0_7","x-ms-request-id":"eastus:7d6bef2f-f726-4f81-bfc9-3b96483b4700"},"config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","accept-language":"en-US","x-ms-client-session-id":"3ec066f0-cb0f-11f0-9062-5fb206e6b131","x-ms-client-request-id":"45efeb9d-1bb0-4879-94ec-de872fc1f258","authorization":""},"operationName":"PROCESSSIMPLE:PATCH/PROVIDERS/MICROSOFT.PROCESSSIMPLE/ENVIRONMENTS/FLOWS/","params":{"api-version":"1","$expand":"properties.connectionreferences.apidefinition,properties.definitionsummary.operations.apioperation,operationDefinition,plan,properties.throttleData,properties.estimatedsuspensiondata,properties.licenseData,properties.billingContext,properties.throttlingBehavior,properties.powerFlowType,properties.protectionStatus","telemetryMetadata":"{\"modifiedSources\":\"Portal\"}"},"method":"patch","url":"https://5162741ef526e9639d6129318afedc.14.environment.api.powerplatform.com/powerautomate/flows/72524e5a-e99b-4a61-ba8f-d9e03463bbd8","data":"{\"properties\":{\"connectionReferences\":{\"shared_office365\":{\"id\":\"/providers/Microsoft.PowerApps/apis/shared_office365\",\"connectionName\":\"shared-office365-3711e7a8-9360-4dc3-91c7-a4993216f607\"}},\"definition\":{\"$schema\":\"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#\",\"contentVersion\":\"undefined\",\"parameters\":{\"$authentication\":{\"defaultValue\":{},\"type\":\"SecureObject\"},\"$connections\":{\"defaultValue\":{},\"type\":\"Object\"}},\"triggers\":{\"Recurrence\":{\"type\":\"Recurrence\",\"recurrence\":{\"frequency\":\"Minute\",\"interval\":\"2\",\"startTime\":\"2025-11-26T22:30:00.000Z\",\"timeZone\":\"Romance Standard Time\"}}},\"actions\":{\"Compose\":{\"type\":\"Compose\",\"inputs\":\"@formatDateTime(utcNow(), 'MM')\",\"runAfter\":{}},\"Switch\":{\"type\":\"Switch\",\"expression\":{},\"default\":{\"actions\":{}},\"cases\":{\"Case\":{\"actions\":{\"Send_an_email_(V2)\":{\"type\":\"OpenApiConnection\",\"inputs\":{\"parameters\":{\"emailMessage/To\":\"bart.willocx@organon.com\",\"emailMessage/Subject\":\"test 2\",\"emailMessage/Body\":\"<p class=\\\"editor-paragraph\\\">test 2</p>\",\"emailMessage/Importance\":\"Normal\"},\"host\":{\"apiId\":\"/providers/Microsoft.PowerApps/apis/shared_office365\",\"operationId\":\"SendEmailV2\",\"connectionName\":\"shared_office365\"}}}},\"case\":11}},\"runAfter\":{\"Compose\":[\"SUCCEEDED\"]}}}},\"displayName\":\"test 2\",\"environment\":{\"name\":\"5162741e-f526-e963-9d61-29318afedc14\"}},\"name\":\"72524e5a-e99b-4a61-ba8f-d9e03463bbd8\",\"telemetryMetadata\":{\"modifiedSources\":\"Portal\"}}","team":"PowerAutomate","bodyDetails":{"locale":"en-US"},"axios-retry":{"retryCount":0,"lastRequestTime":1764195477310},"context":{"ppapiContext":{"endpoint":"5162741ef526e9639d6129318afedc.14.environment.api.powerplatform.com"}},"knownServiceId":"ppapi-pauto","activityId":"84584db7-12b2-47e9-b1ae-e423ad9bb396"},"request":{}},"isAxiosError":true}
 
don't know what's wrong here, any help please.  I can setup this flow with multiple "condition" actions and this works. Don't know why the "switch" function is failing.
Categories:
I have the same question (0)
  • Suggested answer
    wolenberg_ Profile Picture
    1,074 Super User 2026 Season 1 on at
    Hello,  the error you’re hitting with the Switch action comes down to how it’s configured. In Power Automate, a Switch must have a valid expression to evaluate (the “On” field). In your flow, that expression is empty ({}), which is why you see the TemplateValidationError.
     
    In the Switch control, set the On field to the output of your Compose step:
    @outputs('Compose')
    This tells the Switch to evaluate the current month number (like 12 for December). Then define your cases using those numbers:
    • Case 12 → send December email
    • Case 03 → send March email
    • Case 06 → send June email
    Once you add that expression, your flow should save and run without errors.
     
    In short: give the Switch an expression (like your Compose output), then add cases for the month numbers. That will resolve the error and let your flow run correctly.
     
     

    If this helped or could help others in the community, feel free to give it a like or a kudo — it helps surface useful answers for everyone!


     
  • Suggested answer
    S-Venkadesh Profile Picture
    1,214 Super User 2026 Season 1 on at
     
    @wolenberg_ is correct, but I’d like to explain it with a screenshot to make the point clearer.
    formatDateTime(utcNow(),'MM')in a Compose action returns an integer (e.g., 12).
    So your case condition can work with an integer value. A case set to 12 will match, and the remaining logic will run correctly—see the screenshot for reference.

     
    I hope this information helps! If it does, please consider giving a 👍.
    Best regards,
    S-Venkadesh
  • BW-26112220-0 Profile Picture
    24 on at
    Hi,
     
    copilot filled out the switch function for me as I was not familiar with this function. 
    I will try to fill out the "on" field correctly. Thank you @wolenberg & @S-Venkadesh for your support.
     
    Copilot also added this to the "settings" tab of the switch function, do I need this ?
     
  • BW-26112220-0 Profile Picture
    24 on at
    Hi just made a basic flow with manual trigger to test for november. I filled out the "on" field of the swicth function to @outputs( 'compose' ) and set the case "december" to the value 11. I still get an error in the switch function when I manually test this flow. In the "send an email" action I just send a basic mail to myself. But I already could save this flow, so that's already a progress ;-)
     
     
  • Verified answer
    wolenberg_ Profile Picture
    1,074 Super User 2026 Season 1 on at
    Hi, you mentioned that you set the Switch "On" field to @outputs('Compose'), which is correct. But then you created a case called "december" and set its value to 11. That’s likely the mismatch.
     
    Here’s what to fix:
    • The Compose action returns a string like "11" (not a number).
    • Your Switch case should match that string exactly — so instead of naming the case "december" and setting the value to 11, name the case "11" (as a string).
     
    Example:
    • Switch On → @outputs('Compose')
    • Case value → "11" (not 11, and not "december")
    Also, make sure the Compose output is formatted as a string:
    formatDateTime(utcNow(), 'MM')
    This returns "01", "02", ..., "12" — all as strings.
     
    If this helped or could help others in the community, feel free to give it a like or a kudo — it helps surface useful answers for everyone!
  • S-Venkadesh Profile Picture
    1,214 Super User 2026 Season 1 on at
     
    Hi, it appears the switch case is now working, but the email action is causing an error.
    Could you please show what’s configured in the email action, preferably with a screenshot of all actions?
     
    I hope this information helps! If it does, please consider giving a 👍.
    Best regards,
    S-Venkadesh
  • Verified answer
    BW-26112220-0 Profile Picture
    24 on at
    Hi,
     
    resolved. I changed the case "equals"  to "11" and now the flows runs succesfully. "december" was just the case name.
    Thank you so much for your support.
    Greetings, Bart
     

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
trice602 Profile Picture

trice602 224 Super User 2026 Season 1

#2
David_MA Profile Picture

David_MA 185 Super User 2026 Season 1

#3
Kalathiya Profile Picture

Kalathiya 94 Super User 2026 Season 1

Last 30 days Overall leaderboard