spring-projects / spring-projects/spring-data-rest

POST PUTon associations throws http 405 [DATAREST-777]

Open
#1,110 1 comment 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Florian GOURMELEN opened DATAREST-777 and commented

Hi,

I'm facing a problem updating the association resources

I have an object record that is related to a person (OneToMany)
and an object Document that is related to n records (ManyToMany)

When I want to delete the association of a person to a record this uri works fine

  • uri: http://localhost:8080/records/1/person
  • method: DELETE

However when I want to put back the relation to that person then I get http 405: Request method 'PUT' not supported

  • uri: http://localhost:8080/records/1/person
  • method: PUT
  • content type Text
  • body http://localhost:8080/persons/1

I get the same problem when trying to add a record to a document

  • uri: http://localhost:8080/documents/1/records
  • method: POST or PUT
  • content type Text
  • body http://localhost:8080/document/1

none of these methods seems to be supported

I tried posting the full json containing the associations but no more luck

  • uri: http://localhost:8080/documents
  • method: POST
  • content type: json
  • body:
{"label" : "DocumentFlo", "records" : [{ "id": 1, "label" : "Record1" }]}

then I get "Cannot resolve URI id. Is it local or remote? Only local URIs are resolvable"

but in the doc it's mentionned that all those things are possible, am I doing something incorrect?
http://docs.spring.io/spring-data/rest/docs/2.5.0.M1/reference/html/#repository-resources.association-resource

I've attached my sample project

thanks in advance


Attachments:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.