Embedding Comments on Posts
Continue the Import Tool learning trail by embedding JSONPlaceholder comments on each DEMO_POST as a composite child stream.
This path continues Importing Users and Posts. You already have the Demo User connection, the Demo User import, and working Demo User and Demo Post streams. Here you embed comments as an array on each post instead of creating separate comment instances.
Work through each section in order from top to bottom.
Before you start
Confirm that these pieces from Importing Users and Posts are still in place:
Connection Demo User with Base URL
https://jsonplaceholder.typicode.comImport Demo User with streams Demo User and Demo Post
Custom entities
DEMO_USERandDEMO_POSTDemo Post Depends on Demo User
This continuation uses GET https://jsonplaceholder.typicode.com/comments. Comments belong to posts through postId.
Add the comments array on DEMO_POST
Before you create the Demo Comment stream, add a place on each post where comments can be stored. On the DEMO_POST mixin, create a comments array field with the nested keys you want to import.
Embed as attribute and Field Mapping both need that array before they can list or target it. Add the field first, then configure the Demo Comment stream.
Open
DEMO_POSTin Settings -> Custom Entities, then open its mixin schema.On the Fields tab, choose + and add a field with Key
comments(not only a display Name).Set Type to Array and Array Type to Object. Other types do not appear in the Embed as attribute picker.
Choose + inside the
commentsrow and add nested fields. Set each nested Key toid,name,email, andbody(not a generated UUID), each as Text.Save the mixin schema. If the schema already existed, confirm the new version.

Creating the Demo Comment stream
Add one HTTP stream that reads /comments and writes into the same DEMO_POST target type as Demo Post.
Create the Demo Comment stream
On the Demo User import, choose + New stream and enter:
Name –
Demo CommentConnection – Demo User
Resource name –
Demo CommentMethod – GET
Path –
/commentsRecords path – (response is the array)
Response format – JSON
Pagination method – None (single request)
Choose Sample endpoint to call the path once and list the fields returned for the key picker. Then set:
Key field –
idTarget –
emporix.customEntityTarget type –
DEMO_POST
Save the stream. Demo Comment uses the post target type because comments are embedded on the post document.
Configuring composite child
On the Demo Comment stream row, open the Composite tab and choose Composite child (embedded in a parent). Set:
Parent stream – Demo Post
Linking field (this record → parent) –
postIdParent key field –
idEmbed as attribute –
comments. If the value is not in the list, enter it manually.Child strategy – Embed (parent writes the array)
Save.

The parent stream must run before the child. Confirm the order in Run order or on the Dependency graph tab.

Mapping comment fields
Open Edit mapping and choose the schema
Choose Edit mapping. Choose the Target schema version that includes the comments array. If comments is missing, add it as described in Add the comments array on DEMO_POST, then switch to the new schema version.
Fetch a sample and map fields
Choose Fetch sample. Map each comment field Map from source or with + Add row. Choose Target Field values under comments[], for example comments[].id, comments[].name, comments[].email, and comments[].body or comments[].commentBody. Do not map onto the post-level id, title, or body.
Save and Publish the Demo Comment mapping.

Running and reviewing
Review a post instance
Open a DEMO_POST instance in Custom Instances. Check that Comments shows the embedded records for that post's postId.
Composite child comments do not get their own rows in Imported Data. Review outcomes on the Demo Post stream and on the post instance itself.

What to do next
JSONPlaceholder has the same parent and child pattern for other resources. You can add streams later without changing the connection:
Albums –
/albums(userId) as another standalone type that Depends on Demo UserPhotos –
/photos(albumId) as a composite child embedded on albumsTodos –
/todos(userId) as a standalone type that Depends on Demo User
For more options, see Configuring Streams, Field Mapping, and Running and Monitoring Imports.
Troubleshooting
Embed as attribute shows no results
Add a comments field on the DEMO_POST mixin with Type Array and Array Type Object, Key exactly comments, then save and reopen the Composite tab.
comments is missing from Field Mapping
Add the array on the DEMO_POST mixin with nested Key values id, name, email, and body, save a new schema version, then switch Target schema.
Nested fields show UUID keys
Edit the mixin and set each nested Key to id, name, email, or body. Display Name alone is not enough for mapping.
Target Field shows only parent post fields
Confirm Embed as attribute is comments, the schema version includes the nested keys, and you reopened Edit mapping after saving. Do not map comment fields onto post-level id or body.
Save, Publish, or Map from source stay inactive after a schema change
Delete any row with an empty Target Field (often postId). Refresh the browser, open Edit mapping again, and select the latest Target schema version.
Key field shows ID with a schema warning
Change Key field to id, then Save.
Key field picker is empty
Choose Sample endpoint after you set Path and Records path, then select id from the returned fields.
Comments array is empty after a full run
Confirm Demo Comment is Composite child of Demo Post, linking field postId, and the Demo Comment mapping is published. Check Run order.
Comments fails with embedAttribute / "schema attribute with no name"
Open the Demo Comment Composite tab, set Embed as attribute to comments, choose Save, then run again. An empty embed attribute causes this failure.
Imported Data has no comment rows
Expected for composite children. Open a DEMO_POST instance and review the embedded Comments array.
Last updated
Was this helpful?


