cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kyoder611
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

 

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
ChristianAbata
Super User
Super User

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
v-bacao-msft
Community Support
Community Support

 

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.

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"
    }
  ]
}

 

 

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.

Hi @v-bacao-msft ,

 

That worked perfectly! 

 

Thank you!

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,731)