Connection(many to many) record not being updated for multiple connections using API


I am trying to update a connected record which has many to many relation with another object but it fails to update for multiple using API

there is a similar question but that solution doesn’t work for me either

so the scenario is

object_1 and object_2 has many to to many relation, I am maintaining the relation in object_1, so when I try to update object_1 through API, it works for a single record but for multiple it doesn’t.

to explain through code

object_1[field_2]=[id1] works
object_1[field_2]=[id1,id2] doesn’t work

it saves field_2 as blank.