0

I'm facing an issue when executing a simple program in Javalite where I'm testing an API GET call.

The method fetches the URL and reads the response code. But JavaLite is throwing as exception:

org.javalite.http.HttpException: Failed URL: "https://google.in"

Could someone help me understanding this issue?

My code is:

package com.java.lite;

import org.javalite.http.Get;
import org.javalite.http.Http;
import org.testng.annotations.Test;

public class GetCallTest {

    @Test
    public void getCall() throws Exception {
        System.out.println(ConfigPropertyFile.getPropertyValues()); //This line is executed

        Get get = Http.get(ConfigPropertyFile.getPropertyValues()); //URL being call from another class where I defined a static method.
        System.out.println("Response code" + get.responseCode());
        System.out.println("Response message = `enter code here`" + get.responseMessage());
    }
}
arghtype
  • 4,376
  • 11
  • 45
  • 60
Manoj Lonar
  • 11
  • 1
  • 3

1 Answers1

0

The URL you are trying returns a redirect to https://www.google.co.in/

Please try:

System.out.println(Http.get("https://www.google.co.in/").text());

and you will get a text of the Google home page.

ipolevoy
  • 5,432
  • 2
  • 31
  • 46