【发布时间】:2015-01-06 06:49:38
【问题描述】:
在用户和组之间具有多对多的关系。我想知道如何更新与 SDR 的这种关系。这是我在阅读docs 后到目前为止所尝试的。
curl -X POST -H 'Content-Type: text/uri-list' -d 'http://localhost:8080/rest/users/5' http://localhost:8080/rest/groups/1/users
预期结果:将用户 5 添加到组 1。
实际结果: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
预期结果:将组 1 的所有成员替换为用户 5。
实际结果:按预期工作。
curl -X PUT -H 'Content-Type: text/uri-list' -d @members.txt http://localhost:8080/rest/groups/1/users
members.txt 文件所在的位置:
http://localhost:8080/rest/users/5
http://localhost:8080/rest/users/6
http://localhost:8080/rest/users/7
预期结果:将组 1 的所有成员替换为用户 5、6 和 7。
实际结果:仅添加最后一个用户(在本例中为 7)。
有人可以提供一个关于如何将单个 URI 添加到关联的示例吗?另外,如果可能的话,如何添加或替换具有多个 URI 的关联?
【问题讨论】:
标签: spring spring-boot spring-data-rest