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

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.

View solution in original post

Hi @v-bacao-msft ,

 

That worked perfectly! 

 

Thank you!

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Users online (2,076)