0

i need to insert # symbol in the api request. official documentation transforms https://api.brawlstars.com/v1/players/#2JV9PR99Y to https://api.brawlstars.com/v1/players/%232JV9PR99Y.

so if i send request with %23 i will get 404 Not Found: [{"reason":"notFound","message":"Not found with tag %232JV9PR99Y"}] but with postman i can send requests with %23 replace #. if if send request with # it just returns null json body.

my code:

public Player showPlayerInfo(String playerTag) {
    HttpHeaders headers = new HttpHeaders();
    headers.add("Authorization","Bearer " + bearerToken);

    HttpEntity<String> request = new HttpEntity<String>(headers);
    String url = "https://api.brawlstars.com/v1/players/%232JV9PR99Y"; // testing

    System.out.println(url);
    ResponseEntity<Player> response = restTemplate.exchange(url, HttpMethod.GET, request, Player.class);

    return response.getBody();
}

tried to transform link using java.lang URI and URL. also just delete # or %23 from url. api doesnt get it

HouZz
  • 1
  • Hi & Welcome to [so]! `#` in url is normally a "client side thing", and isn't guaranteed to be sent to server .. https://stackoverflow.com/a/13503246/592355 – xerx593 Nov 12 '22 at 12:40

0 Answers0