Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How to parse params with [] in url to create a GET request endpoint SpringBoot3?

$
0
0

I am working on a decommission project which need to create an exactly identical endpoint matches with a legacy endpoint. The legacy endpoint is written by PHP which is like this:

baseUrl/entities?entityIDs=[410,118]&entityTypes=[2,4]  

I used Java 17 SpringBoot 3 to create a new endpoint like this (controller):

  @GetMapping("/entities")  public List<EntityRow> getEntities(@RequestParam List<Integer> entityIDs,                                             @RequestParam List<Integer> entityTypes){    return this.service.getEntities(entityIDs, entityTypes);  }

which works fine. However, the GET request endpoint is like this:

baseUrl/entities?entityIDs=410,118&entityTypes=2,4

when I updated to the legacy PHP endpoint format which contains '[]', I got errors:

java.lang.IllegalArgumentException: Invalid character found in the request target [/baseUrl/entities?entityIDs=[410,118]&entityTypes=[2,4] ]. The valid characters are defined in RFC 7230 and RFC 3986

It even not able to hit the this.service.getEntities. Wondering is any way in Java SpringBoot 3 can parse the endpoint with '[]' ?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>