Add a record with related data / script block

we did a script to import data from an external api and works fine, but when adding a field that has a relation to another table the script does not insert of gives any error. does anybody has an example or reference for documentation in adding a record with related data on it?

This might be helpful:

The cell value for linked records is an array of objects with the ID of the record you want to link to. If you need more help, please post your code here.