I am writing an API service and kept getting an error message: 400 - Relation Parent must be provided and must be a string or an object with objectId property.
I have two tables: Parent - “Parent_Comment”; Child - “Users”; relation - user_id; 1 to 1 relation.
The service is set relation on Parent_Comment on one of the record.
I set two parameters in Method. See graph below.
Then, I wrote my logic.
I am a newbie. From reading the error message, I guess the parent object has not been formed. I checked my logic several times and could not figure it out. Could someone take a look and see what went wrong? Thanks.
(Value goes into parameter “objectId” is the “objectId” of parent table “Parent_Comment.” Value goes into parameter “username” is the “username” of child table “Users.”
“parent object” of “Set Object Relations” wait for an object with “objectId” property. But you use the object with “comment” property.
“children” of “Set Object Relations” wait for a list with “objectId” string. But you use the object.
Logic for your case:
I don’t know if it’s appropriate, but I would advise you to use the id of user instead of username.
@viktor.liablin Thank you for your quick response. I followed your instruction and re-wrote the logic, but I got an error message: “400 - Cannot read property ‘ObjectId’ of.” Then I tried all sorts of combinations on blocks and had gotten all sorts of errors. Finally, I decided to strip the logic down to one block - “Set Object Relations” and it worked just fine. The values of both parameters are “objectId” of both tables.
It is difficult for me to comprehend these blocks without a “dictionary.” Is there a “dictionary” existed or just I don’t know about it? Use this case as an example. Both of the “Method Arguments” are “object”? So, why do we have to convert “Method Argument objectId” to an object and attach it to “Parent object.” Is this rule also applying to “Children?” Why do we need to use “Create list with?” (The last one I guess it related to one-to-many relation?)
I hope I didn’t ask too much. Anyway, thanks again for the help.