Dealing with relationships via the API

Hello, all!

Using V11 API here.

So that you understand the scenario, I have a many to many relationship between two modules called Pet and Booking.

Currently I am serializing this relationship (to send over a POST request) by the following way:

 

floof_booking_floof_pet:

{ 'add': ['aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee','aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'] }

This creates the new booking with 2 pets linked to it. However I will have to update this at some point (with a PUT request), adding or removing pets, so I cannot simply send ADD again, right? Because I think this will ADD another relationship to them instead of overwriting whatever is already there.

I'd like a way to overwrite the relationships, so whenever I do a PUT request, I can simply send the new relationships. Is it possible?

Thanks a lot!

Parents Reply Children
No Data