Home > other >  How to read query parameter with ^ in the URL
How to read query parameter with ^ in the URL

Time:11-04

I'm trying to implement a callback endpoint for eBay. This endpoint is called by eBay to hand the application a user token.

I can define my endpoint as expected

http://localhost:8080/api/ebay/auth

Nothing unusual here. My enpoint looks like this, really basic:

@RestController
@RequestMapping(path = ["/api/ebay/auth"])
class EbayAuthController {

    @GetMapping(path = [""])
    fun getAccessToken(@RequestParam code: String) {
        println("Auth code: $code")
    }

}

Now eBay passes the parameter code with the value

?code=v^1.1#i^1#r^1#p^3#I^3#f^0#t^[excluded_user_token]&expires_in=299

When I call my endpoint with this data set, it returns 400 Bad Request. I can reproduce this by adding ^ to any request. I read it's an unsafe character to use - but the issue is: Ebay uses this character to return the user token, so I must read it.

When I pass a sample with http://localhost:8080/api/ebay/auth?code=123 it prints the code as expected.

I've never encountered that problem, can anyone help me or point me in the right direction how to solve this?

CodePudding user response:

According to this answer by Dirk Deyne to the question Spring-boot controller error when url contains braces character, you can specify server.tomcat.relaxed-query-chars in your application.properties:

server.tomcat.relaxed-query-chars=^
  • Related