Set Relation between User and a Table Object (City) via API

Hi guys,
In short, I am trying to create a relation between User and a city, all through an API Service that I have created as you can see from the image below.

The error that comes out in the console during debug apparently makes no sense, because the selected city draws it directly from the reference table.

I tried to link them in a “normal” way with a non-System table that does not require the API Service and works, so the problem is not the table but the logic inside the API service.

How can I fix it?

Thanks,
Marco

Take a look:
Set Relation between User and a Table Object (City) via API - User Service - Backendless Support 2022-03-15 05-28-23

Now let’s take a look at the API documentation:

Specifically here:

The problem in your codeless logic is the child object is just a string - a city name. It must be a specific object for which the relationship will be established.

Regards,
Mark

Hi Mark,
Thanks for reply, so to add a relation (in this situation) I have to extract the objectId of the relative city and only then link it?

it worked, placed the two codes here for those who need them!
Thanks Mark