WebCuratorTool / webcurator

The root of the webcurator tool project, containing all modules needed to run a fully functional webcurator tool.
Apache License 2.0
1 stars 1 forks source link

Rest API: http body is NOT supported by GET request of the fetch method of browsers #130

Open leefrank9527 opened 2 months ago

leefrank9527 commented 2 months ago

Rest API: http body is not supported by GET request of the fetch method of browsers. For example:

@GetMapping(path = "", consumes = MediaType.APPLICATION_JSON_VALUE)
 public ResponseEntity<?> get(@RequestBody(required = false) SearchParams searchParams) {
...
}

This rest api is not accessible from client only if the mapping method is changed to PostMapping:

@PostMapping(path = "", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> get(@RequestBody(required = false) SearchParams searchParams) {

We need to go through the rest APIs from the server side. If there are @RequestBody included in the methods, the Mapping shoud be set as PostMapping or other Mappings which support http body. The path maybe duplicated with the other existing PostMapping method, we need to pay attention to that.

hannakoppelaar commented 2 months ago

You can use POST by adding the header X-HTTP-Method-Override: GET. This is a workaround to support both POST and GET. See e.g. https://wct-api.readthedocs.io/en/latest/apis/api-targets_GET.html#body.