Skip to main content

Build a parent and child request body

Build an outbound request body that maps one parent Salesforce record and repeated child records into an API request.

Build a parent and child request body

Build one API request containing a parent Salesforce record and a repeating set of child records. A checkout request might use an Opportunity for the parent and OpportunityLineItems for the line items.

Add the parent Query

In an Outbound Payload, use the plus button before HTTP Request and add a Query. Filter the parent object using a Dynamic Input such as $OPPORTUNITY_ID and limit the result to one record.

Select the parent fields required by the request. Confirm the Query appears before the Action that consumes it.

Add the repeating source

Include the required child relationship or add an earlier Query for the child records. Filter it to the intended parent and select the fields needed for each row.

The source must return the complete intended collection. A limit of one on the child source would produce at most one line item, even if the parent has several.

Model the request array

Select HTTP Request and create the Body structure. At the location where the API expects repeated entries, create an Array Element, such as line_items.

In its mapping editor, select the repeating data from the earlier Query output. This source determines how many array entries Payloads builds.

Add child Elements beneath that array. Map quantity, amount and similar values from the current array record. Apply a Transformation when the API requires a different representation, such as an amount in minor units.

Map parent values

Map fields outside the array from the single-record parent Query, constants or declared Dynamic Inputs. For example, map the customer reference at the root while each product quantity belongs inside the line-items array.

The array provides current-record context to its descendants. Mapping a child field outside the array does not select one child automatically.

Verify generated data

Run with a test parent containing at least two distinct child rows. Open the new Job and inspect:

  1. Start: the expected parent Id was supplied.

  2. Query Actions: the intended parent and children were returned.

  3. HTTP Request: the array has the expected count and distinct values.

  4. HTTP Response: the API accepted the shape or returned a useful validation error.

Also test a parent with no children. Decide whether an empty array satisfies the API contract before enabling automation.

Fix common mapping errors

If the array is empty, check the source Query and filters. If every row repeats the same value, check that child fields use current-array data rather than the parent or a fixed record. If the source is unavailable, check that its Action runs before HTTP Request.

Use Troubleshoot Payload mappings with Job data to follow the value through the sequence.

Did this answer your question?