locked
For Each loop on nodes in a xml message RRS feed

  • Question

  • Hi all.

    I am receiving xml via a http get request, and I'd like to loop through this message, pick out particular element values and take some actions (which include writing various values to a sql database).

    Within each message is one or many jobs. 

    Here's an example containing two jobs...

    <?xml version="1.0" encoding="UTF-8"?>
    <jobs type="array" current_page="1" per_page="2" total_pages="1" total_entries="2">
       <job>
          <id readonly="readonly">17466732</id>
          <job_type readonly="readonly">job</job_type>
          <group_ids>4681</group_ids>
          <status>completed</status>
          <third_party_id>SMO848453</third_party_id>
          <enable_hazards>false</enable_hazards>
          <is_incident>false</is_incident>
          <taggings type="array" />
          <hazards type="array" />
          <time_windows type="array" />
          <required_capacity />
          <negative_time_windows>false</negative_time_windows>
          <customer_name>CP Limited</customer_name>
          <template_name>WATER DELIVERY</template_name>
          <customer_id>2325475</customer_id>
          <customer_third_party_id>5529667334508405</customer_third_party_id>
          <worker_id>55681</worker_id>
          <worker_third_party_id />
          <worker_name>Craig Sanders</worker_name>
          <worker_duration>0.01</worker_duration>
          <published_at type="datetime">2019-03-21T20:32:28+00:00</published_at>
          <published_by readonly="readonly">Craig Sanders</published_by>
          <has_pod readonly="readonly">false</has_pod>
          <signed_at readonly="readonly" />
          <signed_by readonly="readonly" />
          <paused_at />
          <planned_duration>600</planned_duration>
          <planned_start_at type="datetime">2019-03-19T11:00:00+00:00</planned_start_at>
          <planned_end_at type="datetime" readonly="readonly">2019-03-19T11:10:00+00:00</planned_end_at>
          <actual_start_at type="datetime" readonly="readonly">2019-03-21T20:48:31+00:00</actual_start_at>
          <actual_duration readonly="readonly">23</actual_duration>
          <alarm_at type="datetime" />
          <requested_at type="datetime" />
          <code />
          <notes type="array" />
          <adhoc_alert_email_recipient>
             <name />
             <email />
          </adhoc_alert_email_recipient>
          <adhoc_alert_sms_recipient>
             <name />
             <mobile />
          </adhoc_alert_sms_recipient>
          <steps type="array">
             <step>
                <id readonly="readonly">53018224</id>
                <name>Water Delivery Start</name>
                <completed_at type="datetime">2019-03-21T20:48:31+00:00</completed_at>
                <location>
                   <id type="integer">55327132</id>
                   <created_at type="datetime" readonly="readonly">2019-03-19T20:25:10+00:00</created_at>
                   <updated_at type="datetime" readonly="readonly">2019-03-19T20:25:10+00:00</updated_at>
                   <address1 />
                   <address2 />
                   <suburb />
                   <city />
                   <post_code />
                   <country />
                   <province />
                   <region />
                   <state />
                   <formatted_address>1100 Great</formatted_address>
                   <lat type="decimal">-38.932479</lat>
                   <lng type="decimal">172.835872</lng>
                   <deleted_at type="datetime" />
                </location>
                <created_at type="datetime" readonly="readonly">2019-03-19T20:25:10+00:00</created_at>
                <updated_at type="datetime" readonly="readonly">2019-03-21T20:49:00+00:00</updated_at>
                <last_reported_completion_location>
                   <lat type="decimal">-34.7665111227303</lat>
                   <lng type="decimal">170.539240794419</lng>
                   <accuracy type="decimal">10.0</accuracy>
                   <completed_at type="datetime">2019-03-21T20:48:31+00:00</completed_at>
                </last_reported_completion_location>
                <hazards_confirmation type="boolean">false</hazards_confirmation>
             </step>
             <step>
                <id readonly="readonly">53018225</id>
                <name>Water Delivery Finished</name>
                <completed_at type="datetime">2019-03-21T20:48:54+00:00</completed_at>
                <created_at type="datetime" readonly="readonly">2019-03-19T20:25:10+00:00</created_at>
                <updated_at type="datetime" readonly="readonly">2019-03-21T20:49:01+00:00</updated_at>
                <last_reported_completion_location>
                   <lat type="decimal">-36.7665111227303</lat>
                   <lng type="decimal">174.539240794419</lng>
                   <accuracy type="decimal">10.0</accuracy>
                   <completed_at type="datetime">2019-03-21T20:48:54+00:00</completed_at>
                </last_reported_completion_location>
                <hazards_confirmation type="boolean">false</hazards_confirmation>
             </step>
          </steps>
          <custom_fields type="array">
             <custom_field>
                <name>Delivery Information</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Job Type</name>
                <value>*SCHDL-AK - SCHEDULED Delivery 15L Auckland</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Job Description</name>
                <value>ALWAYS need sign &amp; name on PDA!</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Customer Number</name>
                <value>C002260</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Ship-to Name</name>
                <value>Cable Price Limited - Auckland Head Office</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Ship-to Address</name>
                <value>1100 Great </value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Ship-to Code</name>
                <value>4</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Service Order Type</name>
                <value>WATER</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Service Zone Code</name>
                <value />
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Customer Reference (PO Number)</name>
                <value>Hhhhh</value>
                <type>text</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Phone Number</name>
                <value>04 568 1072</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Run Order No</name>
                <value>52.4</value>
                <type>number</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Location</name>
                <value>Auckland Admin lvl 1</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Last Water Delivered</name>
                <value>0</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Last Cups Delivered</name>
                <value>0</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Last Service Date</name>
                <value>21/02/2019</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Service Required?</name>
                <value>0</value>
                <type>checkbox</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Delivery Completed?</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Delivery Completed?</name>
                <value>Yes</value>
                <type>pick_list</type>
                <pick_list_id>107702</pick_list_id>
                <permission>required</permission>
             </custom_field>
             <custom_field>
                <name>Delivery Actions</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Total Number of Bottles Onsite</name>
                <value>1</value>
                <type>number</type>
                <permission>required</permission>
             </custom_field>
             <custom_field>
                <name>Customer Signature</name>
                <value>
                   <signature>
                      <signed_by />
                      <signed_at type="datetime">2019-03-22T09:37:21+13:00</signed_at>
                      <image></image>
                   </signature>
                </value>
                <type>signature</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Purchase Order</name>
                <value>Hghghgfgh</value>
                <type>text</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Driver Notes</name>
                <value>Bla</value>
                <type>text</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Unable to Complete Delivery</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Reason for non-Delivery</name>
                <value />
                <type>pick_list</type>
                <pick_list_id>107703</pick_list_id>
                <permission>required</permission>
             </custom_field>
             <custom_field>
                <name>Non-Delivery Notes</name>
                <value />
                <type>text</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Updates/Changes for SDM</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>What needs to be updated?</name>
                <value />
                <type>text</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Alert SDM - Updates</name>
                <value />
                <type>pick_list</type>
                <pick_list_id>107420</pick_list_id>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Service Required</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Serial Number</name>
                <value />
                <type>text</type>
                <permission>required</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Service Notes</name>
                <value />
                <type>text</type>
                <permission>required</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Photo</name>
                <value />
                <type>image</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Alert SDM Cooler needs Servicing</name>
                <value />
                <type>pick_list</type>
                <pick_list_id>107420</pick_list_id>
                <permission>required</permission>
             </custom_field>
          </custom_fields>
          <invoice>
             <id>1320599</id>
             <number />
             <description />
             <tax_rate>15.0</tax_rate>
             <line_items type="array">
                <line_item>
                   <id>2082572</id>
                   <code>H2O15</code>
                   <description>15L Bottled Water</description>
                   <unit_cost>0.0</unit_cost>
                   <requested_quantity>0.0</requested_quantity>
                   <actual_quantity>0.0</actual_quantity>
                </line_item>
                <line_item>
                   <id>2082573</id>
                   <code>MT0015</code>
                   <description>15L Empty Bottle</description>
                   <unit_cost>0.0</unit_cost>
                   <requested_quantity>0.0</requested_quantity>
                   <actual_quantity>0.0</actual_quantity>
                </line_item>
                <line_item>
                   <id>2082574</id>
                   <code>PCUPS</code>
                   <description>Paper Cups (100 Per Sleeve</description>
                   <unit_cost>0.0</unit_cost>
                   <requested_quantity>0.0</requested_quantity>
                   <actual_quantity>0.0</actual_quantity>
                </line_item>
             </line_items>
          </invoice>
          <created_at type="datetime" readonly="readonly">2019-03-19T20:25:10+00:00</created_at>
          <created_by readonly="readonly">Bulk Job Importer</created_by>
          <updated_at type="datetime" readonly="readonly">2019-03-21T21:14:17+00:00</updated_at>
       </job>
       <job>
          <id readonly="readonly">17466723</id>
          <job_type readonly="readonly">job</job_type>
          <group_ids>4681</group_ids>
          <status>completed</status>
          <third_party_id>SMO848497</third_party_id>
          <enable_hazards>false</enable_hazards>
          <is_incident>false</is_incident>
          <taggings type="array" />
          <hazards type="array" />
          <time_windows type="array" />
          <required_capacity />
          <negative_time_windows>false</negative_time_windows>
          <customer_name>Mainf</customer_name>
          <template_name>WATER DELIVERY</template_name>
          <customer_id>2325473</customer_id>
          <customer_third_party_id>15529667254031403</customer_third_party_id>
          <worker_id>55245</worker_id>
          <worker_third_party_id />
          <worker_name>Paul</worker_name>
          <worker_duration>0.03</worker_duration>
          <published_at type="datetime">2019-03-21T20:48:05+00:00</published_at>
          <published_by readonly="readonly">Paul</published_by>
          <has_pod readonly="readonly">false</has_pod>
          <signed_at readonly="readonly" />
          <signed_by readonly="readonly" />
          <paused_at />
          <planned_duration>600</planned_duration>
          <planned_start_at type="datetime">2019-03-19T11:00:00+00:00</planned_start_at>
          <planned_end_at type="datetime" readonly="readonly">2019-03-19T11:10:00+00:00</planned_end_at>
          <actual_start_at type="datetime" readonly="readonly">2019-03-21T20:48:59+00:00</actual_start_at>
          <actual_duration readonly="readonly">94</actual_duration>
          <alarm_at type="datetime" />
          <requested_at type="datetime" />
          <code />
          <notes type="array" />
          <adhoc_alert_email_recipient>
             <name />
             <email />
          </adhoc_alert_email_recipient>
          <adhoc_alert_sms_recipient>
             <name />
             <mobile />
          </adhoc_alert_sms_recipient>
          <steps type="array">
             <step>
                <id readonly="readonly">53018198</id>
                <name>Water Delivery Start</name>
                <completed_at type="datetime">2019-03-21T20:48:59+00:00</completed_at>
                <location>
                   <id type="integer">55327106</id>
                   <created_at type="datetime" readonly="readonly">2019-03-19T20:24:59+00:00</created_at>
                   <updated_at type="datetime" readonly="readonly">2019-03-19T20:24:59+00:00</updated_at>
                   <address1 />
                   <address2 />
                   <suburb />
                   <city />
                   <post_code />
                   <country />
                   <province />
                   <region />
                   <state />
                   <formatted_address>12 Bell</formatted_address>
                   <lat type="decimal">-34.933297</lat>
                   <lng type="decimal">175.833312</lng>
                   <deleted_at type="datetime" />
                </location>
                <created_at type="datetime" readonly="readonly">2019-03-19T20:24:59+00:00</created_at>
                <updated_at type="datetime" readonly="readonly">2019-03-21T20:48:21+00:00</updated_at>
                <last_reported_completion_location>
                   <lat type="decimal" />
                   <lng type="decimal" />
                   <accuracy type="decimal" />
                   <completed_at type="datetime">2019-03-21T20:48:59+00:00</completed_at>
                </last_reported_completion_location>
                <hazards_confirmation type="boolean">false</hazards_confirmation>
             </step>
             <step>
                <id readonly="readonly">53018199</id>
                <name>Water Delivery Finished</name>
                <completed_at type="datetime">2019-03-21T20:50:33+00:00</completed_at>
                <created_at type="datetime" readonly="readonly">2019-03-19T20:24:59+00:00</created_at>
                <updated_at type="datetime" readonly="readonly">2019-03-21T20:49:56+00:00</updated_at>
                <last_reported_completion_location>
                   <lat type="decimal" />
                   <lng type="decimal" />
                   <accuracy type="decimal" />
                   <completed_at type="datetime">2019-03-21T20:50:33+00:00</completed_at>
                </last_reported_completion_location>
                <hazards_confirmation type="boolean">false</hazards_confirmation>
             </step>
          </steps>
          <custom_fields type="array">
             <custom_field>
                <name>Delivery Information</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Job Type</name>
                <value>*SCHDL-CH - SCHEDULED Delivery 15L Christchurch</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Job Description</name>
                <value>trn lft @ PBT sign. make sure 10PW on site</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Customer Number</name>
                <value>C019645</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Ship-to Name</name>
                <value>Mainf</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Ship-to Address</name>
                <value></value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Ship-to Code</name>
                <value>1</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Service Order Type</name>
                <value>WATER</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Service Zone Code</name>
                <value />
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Customer Reference (PO Number)</name>
                <value />
                <type>text</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Phone Number</name>
                <value>027 584 9341</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Run Order No</name>
                <value>52.1</value>
                <type>number</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Location</name>
                <value>lunch room</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Last Water Delivered</name>
                <value>0</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Last Cups Delivered</name>
                <value>0</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Last Service Date</name>
                <value>14/09/2018</value>
                <type>text</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Service Required?</name>
                <value>0</value>
                <type>checkbox</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Delivery Completed?</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Delivery Completed?</name>
                <value>Yes</value>
                <type>pick_list</type>
                <pick_list_id>107702</pick_list_id>
                <permission>required</permission>
             </custom_field>
             <custom_field>
                <name>Delivery Actions</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Total Number of Bottles Onsite</name>
                <value>2</value>
                <type>number</type>
                <permission>required</permission>
             </custom_field>
             <custom_field>
                <name>Customer Signature</name>
                <value>
                   <signature>
                      <signed_by />
                      <signed_at type="datetime" />
                      <image />
                   </signature>
                </value>
                <type>signature</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Purchase Order</name>
                <value />
                <type>text</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Driver Notes</name>
                <value />
                <type>text</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Unable to Complete Delivery</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Reason for non-Delivery</name>
                <value />
                <type>pick_list</type>
                <pick_list_id>107703</pick_list_id>
                <permission>required</permission>
             </custom_field>
             <custom_field>
                <name>Non-Delivery Notes</name>
                <value />
                <type>text</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Updates/Changes for SDM</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>What needs to be updated?</name>
                <value />
                <type>text</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Alert SDM - Updates</name>
                <value />
                <type>pick_list</type>
                <pick_list_id>107420</pick_list_id>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Service Required</name>
                <value />
                <type>section_header</type>
                <permission>read_only</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Serial Number</name>
                <value />
                <type>text</type>
                <permission>required</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Service Notes</name>
                <value />
                <type>text</type>
                <permission>required</permission>
             </custom_field>
             <custom_field>
                <name>Cooler Photo</name>
                <value />
                <type>image</type>
                <permission>optional</permission>
             </custom_field>
             <custom_field>
                <name>Alert SDM Cooler needs Servicing</name>
                <value />
                <type>pick_list</type>
                <pick_list_id>107420</pick_list_id>
                <permission>required</permission>
             </custom_field>
          </custom_fields>
          <invoice>
             <id>1320596</id>
             <number />
             <description />
             <tax_rate>15.0</tax_rate>
             <line_items type="array">
                <line_item>
                   <id>2082559</id>
                   <code>H2O15</code>
                   <description>15L Bottled Water</description>
                   <unit_cost>0.0</unit_cost>
                   <requested_quantity>0.0</requested_quantity>
                   <actual_quantity>0.0</actual_quantity>
                </line_item>
                <line_item>
                   <id>2082560</id>
                   <code>MT0015</code>
                   <description>15L Empty Bottle</description>
                   <unit_cost>0.0</unit_cost>
                   <requested_quantity>0.0</requested_quantity>
                   <actual_quantity>0.0</actual_quantity>
                </line_item>
                <line_item>
                   <id>2082561</id>
                   <code>PCUPS</code>
                   <description>Paper Cups (100 Per Sleeve</description>
                   <unit_cost>0.0</unit_cost>
                   <requested_quantity>0.0</requested_quantity>
                   <actual_quantity>0.0</actual_quantity>
                </line_item>
             </line_items>
          </invoice>
          <created_at type="datetime" readonly="readonly">2019-03-19T20:24:59+00:00</created_at>
          <created_by readonly="readonly">Bulk Job Importer</created_by>
          <updated_at type="datetime" readonly="readonly">2019-03-21T20:49:56+00:00</updated_at>
       </job>
    </jobs>
     

    So I want to create a ForEach loop which is based on the job element i.e. for each job I want to loop through and extract various field values which I'll build into a call to write to an on-prem database.

    Within each job node there is another level which I may need to loop through as well (e.g. step), so I may have a For Each within my For Each loop.

    My question is, how do I specify my For Each action to identify each Job node? I've spent all afternoon trying various suggestions I've tracked down online with little success. Is this even possible? I appreciate there are probably much smarter ways of achieving this, but I'm familiar with xml (more so than json, for example), so have stuck with this approach.  

    My latest attempt was...

    xpath(xml(body('Http')), '/*[local-name()="Jobs"] /*[local-name()="Job"]')

    I appreciate any assistance or suggestions :)

    Thanks

    Craig

    Friday, March 22, 2019 2:43 AM

Answers

  • Hi ,

    I usually prefer changing the content type from xml to json so that I can work easy with available connector .

    I have worked through your sample and below the definition of the workflow 

    {
        "definition": {
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "actions": {
                "For_each": {
                    "actions": {
                        "HTTP": {
                            "inputs": {
                                "body": "@items('For_each')",
                                "method": "POST",
                                "uri": "https://webhook.site/34f8e718-bfd9-4c3e-a9eb-3b44a2f543fd"
                            },
                            "runAfter": {},
                            "type": "Http"
                        }
                    },
                    "foreach": "@json(xml(triggerBody()))?['jobs']?['job']",
                    "runAfter": {},
                    "type": "Foreach"
                }
            },
            "contentVersion": "1.0.0.0",
            "outputs": {},
            "parameters": {},
            "triggers": {
                "manual": {
                    "inputs": {
                        "schema": {}
                    },
                    "kind": "Http",
                    "type": "Request"
                }
            }
        }
    }
    This will resolve your issue ,save this workflow and test through http client like postman


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply

    Friday, March 22, 2019 3:07 AM
  • Hi Abhishek. This looks very, very promising.

    I have tested something based on your response and I have been able to pull out a couple of different records from a single xml message. I now just have to get my head around the json thing!

    Much appreciated :)

    Craig

    Tuesday, March 26, 2019 7:09 AM

All replies

  • Hi ,

    I usually prefer changing the content type from xml to json so that I can work easy with available connector .

    I have worked through your sample and below the definition of the workflow 

    {
        "definition": {
            "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "actions": {
                "For_each": {
                    "actions": {
                        "HTTP": {
                            "inputs": {
                                "body": "@items('For_each')",
                                "method": "POST",
                                "uri": "https://webhook.site/34f8e718-bfd9-4c3e-a9eb-3b44a2f543fd"
                            },
                            "runAfter": {},
                            "type": "Http"
                        }
                    },
                    "foreach": "@json(xml(triggerBody()))?['jobs']?['job']",
                    "runAfter": {},
                    "type": "Foreach"
                }
            },
            "contentVersion": "1.0.0.0",
            "outputs": {},
            "parameters": {},
            "triggers": {
                "manual": {
                    "inputs": {
                        "schema": {}
                    },
                    "kind": "Http",
                    "type": "Request"
                }
            }
        }
    }
    This will resolve your issue ,save this workflow and test through http client like postman


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply

    Friday, March 22, 2019 3:07 AM
  • Hi Craig - Any updates on this?
    Monday, March 25, 2019 10:22 PM
  • Hi Abhishek. This looks very, very promising.

    I have tested something based on your response and I have been able to pull out a couple of different records from a single xml message. I now just have to get my head around the json thing!

    Much appreciated :)

    Craig

    Tuesday, March 26, 2019 7:09 AM