cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

HTTP Post with Array within Array

Hello,

I am trying to create a solution to get purchase orders from one database and post them into another database as a sales order. I am using a custom HTTP connector for the data source. The issue that I am running into is that I have an array within an array. It can also pull multiple purchase orders when it is run. Currently it is creating a different sales order for every line inside the purchase order. How do I can dynamically build the array for the line items inside the apply to each for the Purchase Orders?

Capture.PNG

Capture2.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: HTTP Post with Array within Array

 

Hi @Kyoder611 ,

 

You need to add Set variable action under HTTP action to clear the array variable.

Image reference:

12.PNG

Hope it helps.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Highlighted
Super User
Super User

Re: HTTP Post with Array within Array

hi @Kyoder611  you can try by creating a varible array to catch the frist array that you need to send into your another Json.

See the examplejson.PNG



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA
Highlighted
Community Support
Community Support

Re: HTTP Post with Array within Array

 

Hi @Kyoder611 ,

 

As @ChristianAbata suggested, you could append the items in the array to a variable and configure it to the Body, like:

131.PNG132.PNG

Please take a try and feel free to let us know if you have any questions.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Frequent Visitor

Re: HTTP Post with Array within Array

Hi @v-bacao-msft ,

 

As you and @ChristianAbata I created a variable to append the arrays of the Apply to each 2. This does work correctly on the first record but on all the subsequent records it adds all of the details from the previous records.

 

Here is my GET

[
    {
      "ID": "V_TESTAPI",
      "PO_NO": "                     8481",
      "APINVDETs": [
        {
          "O_QUAN_VIS": 20,
          "INVEN": "TEST_1",
          "DESCR": "Test Inventory Code"
        },
        {
          "O_QUAN_VIS": 12,
          "INVEN": "TEST_2",
          "DESCR": "Test Inventory Code"
        }
      ]
    },
    {
      "ID": "V_TESTAPI",
      "PO_NO": "                     8488",
      "APINVDETs": [
        {
          "O_QUAN_VIS": 11,
          "INVEN": "TEST_2",
          "DESCR": "Test Inventory Code"
        },
        {
          "O_QUAN_VIS": 18,
          "INVEN": "TEST_1",
          "DESCR": "Test Inventory Code"
        }
      ]
    }
  ]

 

Here is the first POST of the Apply to Each:

{
  "ID": "C_TESTAPI",
  "PO_NO": "8481",
  "ARINVDETs": [
    {
      "M_QUAN_VIS": 20,
      "INVEN": "TEST_1",
      "DESCR": "Test Inventory Code"
    },
    {
      "M_QUAN_VIS": 12,
      "INVEN": "TEST_2",
      "DESCR": "Test Inventory Code"
    }
  ]
}

 

Here is the second POST of the Apply to Each:

{
  "ID": "C_TESTAPI",
  "PO_NO": "8488",
  "ARINVDETs": [
    {
      "M_QUAN_VIS": 20,
      "INVEN": "TEST_1",
      "DESCR": "Test Inventory Code"
    },
    {
      "M_QUAN_VIS": 12,
      "INVEN": "TEST_2",
      "DESCR": "Test Inventory Code"
    },
    {
      "M_QUAN_VIS": 11,
      "INVEN": "TEST_2",
      "DESCR": "Test Inventory Code"
    },
    {
      "M_QUAN_VIS": 18,
      "INVEN": "TEST_1",
      "DESCR": "Test Inventory Code"
    }
  ]
}

 

Highlighted
Community Support
Community Support

Re: HTTP Post with Array within Array

 

Hi @Kyoder611 ,

 

You need to add Set variable action under HTTP action to clear the array variable.

Image reference:

12.PNG

Hope it helps.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Frequent Visitor

Re: HTTP Post with Array within Array

Hi @v-bacao-msft ,

 

That worked perfectly! 

 

Thank you!

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (7,604)