1

I'm trying to write a program that makes api calls to Battle.net API, then sorts the characters by their points to create a ranking. My problem is, whenever I call for a character with a special character letter in their name, the call doesn't go through.

I have checked the URL that is sent by hand, and I have gotten the correct API response. I have tried printing every step of the way in my terminal. It seems like the URL is combined correctly despite the special characters - it prints in my terminal correctly - but it seems like the program has a problem with making the call. The whole program is pretty long, so I'll try to only include the part I think is relevant - please let me know if I should add more / all code.

temp = "https://" + region + ".api.blizard.com/wow/character/" + realm + "/" 
        + name + "?fields=achievements&locale=en_" + region 
        + "&access_token=" + access_token + "";    
System.out.println(temp);  //this prints the URL in terminal correctly    
String apiCall = new Scanner(new URL(temp).openStream(), "UTF-8")
         .useDelimiter("\\A").next();    
System.out.println(apiCall); 

// this prints the whole response, but only does so for characters without 
// special characters in their names. 

This is the first program I'm writing that's not a school assignment, so sorry if my descriptions are too vague, I will try to provide as much information as I can if needed. Thank you!

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • Instead of appending the parameters values directly via `+` make sure to url escape / encode them before doing so. There are many characters that have special meaning in a url or just aren't supported without url encoding them – roookeee Jul 05 '19 at 10:44

0 Answers0