CodexBloom - Programming Q&A Platform

Azure Logic Apps: How to Implement Conditional Actions Based on HTTP Response Status Code

πŸ‘€ Views: 76 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-08
azure logic-apps http conditional-actions json

Quick question that's been bugging me - I'm working on a personal project and I've searched everywhere and can't find a clear answer. I'm working on an Azure Logic App that needs to perform different actions based on the HTTP response status code from a REST API call. My current setup is a simple HTTP action that makes a GET request, followed by a switch case to handle different status codes. However, it seems that the switch action is not triggering as expected, and I need to figure out why. Here’s the relevant part of my Logic App definition: ```json { "definition": { "$schema": "http://schema.management.azure.com/schemas/2016-06-01/workflowdefinition.json#", "actions": { "HTTP": { "inputs": { "method": "GET", "uri": "https://api.example.com/data" }, "runAfter": {}, "type": "Http" }, "Switch": { "actions": { "Success": { "inputs": { "statusCode": "200" }, "runAfter": { "HTTP": ["Succeeded"] }, "type": "Http" } }, "expression": "@{outputs('HTTP')['statusCode']}", "runAfter": { "HTTP": ["Succeeded"] }, "type": "Switch" } } } } ``` When I test this Logic App, I receive a 200 status code from the API, but the cases inside the switch action do not execute. I've checked the expression and everything seems correct, yet it behaves as if the status code is not matching any of my cases. I've also tried moving the Switch action directly after the HTTP action without success. The Azure portal doesn't show any errors during execution, and I’ve confirmed that the API endpoint is reachable. Is there a specific format or syntax that I might be missing in the switch expression, or any configuration options I should check? Any insights would be greatly appreciated! For context: I'm using Json on Linux. How would you solve this? For context: I'm using Json on macOS. What's the best practice here? I'm coming from a different tech stack and learning Json. I'd love to hear your thoughts on this. Thanks for your help in advance!