Search code examples
androidasciiillegalargumentexceptionsslhandshakeexceptionjavax

how to call Web Service with url which contains underscore


in my build.gradle I have some thing like that:

productFlavors {
    dev {
      buildConfigField "String", "BASE_URL", '"https://uat_mobile.xxxxx.com/something/rest/json/"'
    }
}

the problem is when I try to call a WS I have this error which appears because of underscore in url:

javax.net.ssl.SSLHandshakeException: java.lang.IllegalArgumentException: Invalid input to toASCII: uat_mobile.xxxxx.com

What is the workaround to this problem please ?

In advance thank you,


Solution

  • I have faced this issue at my organization, they used underscore "_" for sub-domains, I did a workaround for it you can try the following:

    • Open your terminal or console command line app.
    • Type:

      ping mohammedfathy.wordpress.com

      PING lb.wordpress.com (192.0.78.12) 56(84) bytes of data.

    • Use "lb.wordpress.com" instead it will re-route to the same link. Also sometimes you can use the IP instead of the link, those steps always works with me.