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 - General Discussion
Answered

Append JSON string with JSON from HTTP request

(0) ShareShare
ReportReport
Posted on by

Hi forum,

 

Must be a very easy issue to solve but I don't find a way to do it...

 

I perform a first HTTP request, I extract the body and store the JSON as string in a Sharepoint List:

 

Sample of this JSON stored as string in my Sharepoint List:

 

{
 "general": {
 "accountName": "Account 1",
 "accountGroup": "Group ABC"
 },
 "hq": {
 "accountAddress": "Alpha street 45",
 "accountZipCode": "78528",
 "accountCity": "Wien",
 "accountCountry": "Austria"
 },
 "Contacts": [
 {
 "LastName": "Doe",
 "FirstName": "John",
 "JobTitle": "GM",
 "Email": "doe.john@ss.com"
 }
 ]
}

 

 
I then perform a new HTTP request, and I extract the body again:

 

{
 "general": {
 "accountName": "Account 2",
 "accountGroup": "Group ABC"
 },
 "hq": {
 "accountAddress": "Beta street 78",
 "accountZipCode": "78566",
 "accountCity": "Wien",
 "accountCountry": "Austria"
 },
 "Contacts": [
 {
 "LastName": "Jones",
 "FirstName": "Allan",
 "JobTitle": "GM",
 "Email": "jone.allan@ss.com"
 }
 ]
}

 

 

Now I want to Update my Sharepoint list and append the new HTTP request Body to my previously extracted version stored as String.

 

My append of both should in this case looks like this:

 

[
 {
 "general": {
 "accountName": "Account 1",
 "accountGroup": "Group ABC"
 },
 "hq": {
 "accountAddress": "Alpha street 45",
 "accountZipCode": "78528",
 "accountCity": "Wien",
 "accountCountry": "Austria"
 },
 "Contacts": [
 {
 "LastName": "Doe",
 "FirstName": "John",
 "JobTitle": "GM",
 "Email": "doe.john@ss.com"
 }
 ]
 },
 {
 "general": {
 "accountName": "Account 2",
 "accountGroup": "Group ABC"
 },
 "hq": {
 "accountAddress": "Beta street 78",
 "accountZipCode": "78566",
 "accountCity": "Wien",
 "accountCountry": "Austria"
 },
 "Contacts": [
 {
 "LastName": "Jones",
 "FirstName": "Allan",
 "JobTitle": "GM",
 "Email": "jone.allan@ss.com"
 }
 ]
 }
]

 

 

I tried extracting my string JSON, store it in a JSON variable and play with append to variable (JSON) but didn't succeed. Not sure what I'm doing wrong..

 

Thanks for the help

 

Best regards

Chris

I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    on at
    Re: Append JSON string with JSON from HTTP request

    Hi @ChrisBI ,

     

    I made a sample for you.

    vxiaochenmsft_0-1697420304320.png

    vxiaochenmsft_1-1697420314261.png

    vxiaochenmsft_2-1697420490450.png

    vxiaochenmsft_3-1697420510792.png

    vxiaochenmsft_4-1697420522921.png

     

    Best Regards,

    Wearsky

  • CH-22072116-0 Profile Picture
    on at
    Re: Append JSON string with JSON from HTTP request

    Hi Wearsky,

     

    Thank you very much for you fast response. It indeed did the trick but only works the first time.

     

    When I have 1 account stored as string it works

    {
     "general": {
     "accountName": "Account 1",
     "accountGroup": "Group ABC"
     },
     "hq": {
     "accountAddress": "Alpha street 45",
     "accountZipCode": "78528",
     "accountCity": "Wien",
     "accountCountry": "Austria"
     },
     "Contacts": [
     {
     "LastName": "Doe",
     "FirstName": "John",
     "JobTitle": "GM",
     "Email": "doe.john@ss.com"
     }
     ]
    }

     

    It correctly stores the new string in the Sharepoint list:

    [
     {
     "general": {
     "accountName": "Account 1",
     "accountGroup": "Group ABC"
     },
     "hq": {
     "accountAddress": "Alpha street 45",
     "accountZipCode": "78528",
     "accountCity": "Wien",
     "accountCountry": "Austria"
     },
     "Contacts": [
     {
     "LastName": "Doe",
     "FirstName": "John",
     "JobTitle": "GM",
     "Email": "doe.john@ss.com"
     }
     ]
     },
     {
     "general": {
     "accountName": "Account 2",
     "accountGroup": "Group ABC"
     },
     "hq": {
     "accountAddress": "Beta street 78",
     "accountZipCode": "78566",
     "accountCity": "Wien",
     "accountCountry": "Austria"
     },
     "Contacts": [
     {
     "LastName": "Jones",
     "FirstName": "Allan",
     "JobTitle": "GM",
     "Email": "jone.allan@ss.com"
     }
     ]
     }
    ]

     

    But if I run it again to add 1 more account then it fails on the Append to array that converts the string to JSON with the next error message:

    InvalidTemplate. Unable to process template language expressions in action 'Append_to_array_variable_-_Get_existing_String_JSON' inputs at line '0' and column '0': 'The template language function 'json' parameter is not valid. The provided value xxxx cannot be parsed: 'Invalid property identifier character: [. Path '', line 1, position 1.

     

    If you have an idea I would appreciate, I'll try to play more in depth this evening and try to find a way to solve this as well.

     

    Thanks you very much for all your support

    Chris

  • Chriddle Profile Picture
    8,319 Super User 2025 Season 2 on at
    Re: Append JSON string with JSON from HTTP request

    OK, I've just seen your next comment, so this (createArray) does not really help😉

    You should check, if your list value is empty and - if so - already add the first JSON as a (stringified) array,

    so you just have to append to this array without having to take care of the type of the existing list value.

     

     

    Consider function createArray

    https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#createArray

     

    Chriddle_0-1697451159083.png

     

    string(
    	createArray(
    		outputs('Data0'),
    		outputs('Data1')
    	)
    )

     

    This returns the stringified array:

     

    [{"general":{"accountName":"Account 1","accountGroup":"Group ABC"},"hq":{"accountAddress":"Alpha street 45","accountZipCode":"78528","accountCity":"Wien","accountCountry":"Austria"},"Contacts":[{"LastName":"Doe","FirstName":"John","JobTitle":"GM","Email":"doe.john@ss.com"}]},{"general":{"accountName":"Account 2","accountGroup":"Group ABC"},"hq":{"accountAddress":"Beta street 78","accountZipCode":"78566","accountCity":"Wien","accountCountry":"Austria"},"Contacts":[{"LastName":"Jones","FirstName":"Allan","JobTitle":"GM","Email":"jone.allan@ss.com"}]}]

     

     

  • CH-22072116-0 Profile Picture
    on at
    Re: Append JSON string with JSON from HTTP request

    Thanks @Chriddle 

     

    Tried that as well and I already had a string() in my update item.

     

    The problem occurs when I start adding a third account, then my Append isn't happy because it's already an array.

     

    My first Append to array uses JSON(outputs('Get_item')?['body/JSONAccountcreation']) and crashes if the data is an array (error in previous post)

     

    I'm using the String() when I'm updating the item. If I remove the JSON() from the first Append array then it works, but it gives me a string in the array that is append to the object, see code block:

     

    [
     "[{\"general\":{\"accountName\":\"qf\", ....
    {
     "general": {
     "accountName": "qsdf",

     

    Not sure what I'm doing wrong 😕

  • Verified answer
    Chriddle Profile Picture
    8,319 Super User 2025 Season 2 on at
    Re: Append JSON string with JSON from HTTP request

    I created an example flow with your HTTP Responses in 2 Compose actions.

    It does thwe following steps:

    • Check if this account group exists.
    • If not, create a list entry for it and add the first JSON (note that the JSON will be inserted into an array and converted to a string).
    • If it exists, take its JSON from the list, put it in an (array) variable (note that you need to use the json(...) function to turn the string into an array of objects ) and append the new JSON to this variable.
    • Update the list item with this stringified array.

     

    Chriddle_0-1697528345450.png

    Chriddle_2-1697528638656.png

     

    Expressions used in the flow:

     

    "Get Items"

    Filter Query:

    Title eq '@{outputs('ResultFromHttpRequest_0')['general/accountGroup']}'

     Compose "ItemToUpdate"

    first(outputs('Get_items')?['body/value'])

     "Set variable TmpJson to Json from List"

    Value:

    json(outputs('ItemToUpdate')['Json'])

     "Append new Json to array variable TmpJson"

    Value:

    outputs('ResultFromHttpRequest_1')

     "Update item"

    item:

    {
     "Json": @{string(variables('TmpJson'))}
    }

    "Create item"

    item:

    {
     "Title": @{outputs('ResultFromHttpRequest_0')['general/accountGroup']},
     "Json": @{string(array(outputs('ResultFromHttpRequest_0')))}
    }

     

    After the first run, the list looks like this:

    Chriddle_3-1697529652130.png

    after second run:

    Chriddle_4-1697529731281.png

    and of course you can add more JSONs there.

     

  • CH-22072116-0 Profile Picture
    on at
    Re: Append JSON string with JSON from HTTP request

    Hi @Chriddle 

     

    You're my hero, works like a charm now !

     

    Thanks you so much @v-xiaochen-msft and @Chriddle  for helping me solving my issue.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

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 722 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 461 Moderator

#3
developerAJ Profile Picture

developerAJ 283

Last 30 days Overall leaderboard