Open atulshivade opened 3 years ago
import java.io.IOException; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response;
public class OKHTTPClientGet { public static void main(String[] args) throws IOException { OkHttpClient okClient = new OkHttpClient().newBuilder().build(); Request request = new Request.Builder().url("https://cdn-api.co-vin.in/api/v2/admin/location/states").get().addHeader("accept", "application/json").addHeader("Accept-Language", "en_US").addHeader("Connection", "keep-alive") .addHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36").build(); Response resp = okClient.newCall(request).execute(); System.out.println(resp.body().toString()); } }
Hi @atulshivade, As of now we can only access the API calls from an Indian IP address, So kindly try hosting them in Indian servers, possibly servers in Mumbai regions seems to work fine.
Can you please give access to public APIs outside india ? For ex. I am trying to call https://cdn-api.co-vin.in/api/v2/admin/location/states from POSTMAN, it works.
But from my java code it says: java.net.UnknownHostException: cdn-api.co-vin.in