Logic Apps (standard) designer Response action returning a JSON string overwrites code data object leading to error

Conor Atkins 0 Reputation points
2025-01-23T22:51:39.0166667+00:00

I have migrate a consumption logic app project with multiple apps calling each other to standard. One logic app returns a JSON response using the return action. When using the designer in portal.azure.com and setting the response string to be the JSON string {"value": "@{outputs('Compose')}"} there is an error when running.

InvalidTemplate Unable to process template language expressions in action 'Response' inputs at line '0' and column '0': 'Template language expression cannot be evaluated: one of string interpolation segments is not valid. The value cannot be converted to string.'.

The expected Code view for this action is:

{
  "type": "Response",
  "kind": "Http",
  "inputs": {
    "statusCode": 200,
    "headers": {
      "Content-Type": "application/json"
    },
    "body": "{\"value\": \"@{outputs('Compose')}\"}"
  },
  "runAfter": {
    "Compose": [
      "SUCCEEDED"
    ]
  }
}

But what I get is:

{
  "type": "Response",
  "kind": "Http",
  "inputs": {
    "statusCode": 200,
    "headers": {
      "Content-Type": "application/json"
    },
    "body": {
      "value": "@{outputs('Compose')}"
    }
  },
  "runAfter": {
    "Compose": [
      "SUCCEEDED"
    ]
  }
}

Notice how the "body" value has become and object rather than the string of JSON I wanted to return.

Adding any text before the response body in the designer like a{"transcript_file_url": "@{outputs('Compose')}"} turns "body" back into a string, but the response with not be perfect JSON.

Editing in Code View does not fix this as it reverts back.

The value that I am trying the return is a shared URI to a blob generated in a previous action. It seems that there is a problem with this blob uri data in particular. I was able to sucessfully return the whole blob uri generating action body, but this restrict the output of a logic app to being only {"blobUri": "..."}.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,322 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Loknath Mahali 0 Reputation points Microsoft Vendor
    2025-01-24T07:36:38.1566667+00:00

    Hello @Conor Atkins,

    Greetings, for the day.
    Welcome to Microsoft Q&A Platform! Thanks for reaching out.

    It seems like you are having trouble returning a JSON response using the return action in a Logic App. Based on the error message you provided, it seems like there is an issue with the string interpolation segments in your response string.

    To fix this issue, you can try using double quotes instead of single quotes around the expression in your response string. For example, you can change your response string to:

    {"value": "@{outputs("Compose")}"}

    This should allow the string interpolation to be evaluated correctly and return the JSON response you are expecting.

    If you still encounter issues, you can try adding a "Parse JSON" action before the "Response" action to ensure that the output from the "Compose" action is in the correct format.

    If you find the answer helpful, kindly click "Accept Answer" and upvote it. If you have any further questions or concerns, please feel free to reach out to us. We are happy to assist you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.