Linking updates for many
A many-to-many relationship between users and groups. I would like to know how to update this relationship using SDR. This is what I have tried so far after reading the docs .
curl -X POST -H 'Content-Type: text/uri-list' -d 'http://localhost:8080/rest/users/5' http://localhost:8080/rest/groups/1/users
Expected Result : Add user 5 to group 1.
Actual result : 405 Method not allowed.
curl -X PUT -H 'Content-Type: text/uri-list' -d 'http://localhost:8080/rest/users/5' http://localhost:8080/rest/groups/1/users
Expected Result : Replace all members of group 1 with user 5.
Actual Result : Works as expected.
curl -X PUT -H 'Content-Type: text/uri-list' -d @members.txt http://localhost:8080/rest/groups/1/users
Where is the members.txt file:
http://localhost:8080/rest/users/5
http://localhost:8080/rest/users/6
http://localhost:8080/rest/users/7
Expected result . Replace all members of group 1 with users 5, 6, and 7.
Actual result : only the last user is added (in this case 7).
Can anyone provide an example of how to add one URI to an association ?. Also, if possible, how do I add or replace the association with multiple URIs?
source to share
After checking the documentation again, indeed, POST should add to the collection.
My experience has been to use PATCH to add to a collection.
To answer further: you should be able to use PUT CONTENT-TYPE: text / uri-list with a content body that has multiple URIs. Each URI is separated by a line break "\ n"
source to share