I am trying to call a api in java using rest template, when I run the code I am able to get response from the api but when I deploy the code on my jboss server I am getting unknown host exception error
I am calling a public api using an api in java
CodePudding user response:
as described by you the API is running locally I am assuming.
More details about your error: https://docs.oracle.com/javase/7/docs/api/java/net/UnknownHostException.html
Thrown to indicate that the IP address of a host could not be determined.
Which points to an error with your host (target) configurations. Few points you should look into:
- Machine which is running the application can speak to the public API endpoint.
- In your code you need to make sure you are not replacing the API endpoint address anywhere in the code.
- Application machine can resolve the DNS of the API endpoint
Your app should work fine once these are taken care. Hope this helps. Happy Coding.
CodePudding user response:
These are 2 ways I know
RestClient
OkHttpClient
you can google about these client and use it.