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

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

error message with "switch" function

(1) ShareShare
ReportReport
Posted on by 2
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.
I have the same question (0)
  • Suggested answer
    wolenberg_ Profile Picture
    887 Moderator on at
    error message with "switch" function
    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
    824 Moderator on at
    error message with "switch" function
     
    @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

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

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 493 Moderator

#3
Expiscornovus Profile Picture

Expiscornovus 246 Most Valuable Professional

Last 30 days Overall leaderboard