Kenny_I
Kenny_I

Reputation: 2503

How to create string variable from array in Azure LogicApps?

I have LogicApp which get HTTP Post from Azure Alerts. I would like to create "DimensionNames" string variable, which includes all names in array. DimensionNames value could be "name1,name2, name3, name4". Finally I would use DimenstionNames string in "call Webhook".

How do it?

Request Body Json in "When a HTTP request is received"

{
  "dimensions": {
    "items": {
      "properties": {
        "name": {
          "type": "string"
        },
        "value": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "value"
      ],
      "type": "object"
    },
    "type": "array"
  }
}

Upvotes: 0

Views: 1003

Answers (1)

vijaya
vijaya

Reputation: 1721

Using variables and Join action you can convert array to a string variable. I have reproduced from my side and below are steps I followed,

  1. Created an alert and configured a HTTP trigger logic app to it.
  2. Designer of logic app will be, enter image description here
  3. The payload of http request is,
{
"dimensions": {
"items": {
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"name",
"value"
],
"type": "object"
},
"type": "array"
}
}

enter image description here 4. Next taken Initialize variable action as shown below, enter image description here

  1. Taken Join action to divide values from array with comma, enter image description here
  2. Next taken another initialize variable action to store value as a string, enter image description here
  3. In webhook action the value of string variable is used as body, enter image description here
  4. Outputs are shown below,

Http trigger:

enter image description here

Output of initialize variable, enter image description here

Output if Join,

enter image description here

Output of initialize variable 2,

enter image description here

Reference link

Upvotes: 1

Related Questions