cancel
Showing results for 
Search instead for 
Did you mean: 

Slash in Input Path String is not handled in CAP?

spenceryang
Product and Topic Expert
Product and Topic Expert
0 Kudos
716

Hi Colleagues,

I have a CAP service Entity MyService, primary keys are (id, displayed). It fails when I get as

localhost:8090/odata/v4/test/MyService(id=54642296-8b91-4145-a579-0e4d5a51cdb6,displayId='M-EUR/CNY-20210809')


The error message is 400: "The key value 'displayId' is invalid."

It might because of the slash in `displayId='M-EUR/CNY-20210809')` since it works without slash. So i replace / with %2F. But returns 400 from apache (not from cap service) Message Invalid URI: [The encoded slash character is not allowed].

I am wondering if in CAP there is an option to enable slash char handling?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

marcbecker
Product and Topic Expert
Product and Topic Expert

Slashes need to be encoded, if they should not be handled as a actual path separator., but as a character of a path segment. However Spring Boot and Tomcat reject encoded slashes in URLs by default due to security concerns. You need to explicitly configure Spring Boot and Tomcat to allow encoded slashes in URLs:

You can find some hints here how to configure this correctly: https://stackoverflow.com/questions/13482020/encoded-slash-2f-with-spring-requestmapping-path-param-.... If you are using Tomcat 10 (CAP Java 2.0) make sure you take a look at this answer: https://stackoverflow.com/a/76128441

Answers (0)