我在Javalite中执行一个简单的程序时遇到了一个问题,我在Javalite中测试API GET调用。
该方法获取URL并读取响应代码。但是JavaLite抛出了一个异常:
org.javalite.http.HttpException: Failed URL: "https://google.in"有人能帮我理解这个问题吗?
我的代码是:
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());
}
}发布于 2017-01-18 15:20:08
您正在尝试的URL返回到https://www.google.co.in/的重定向
请尝试:
System.out.println(Http.get("https://www.google.co.in/").text());您将获得Google主页的文本。
https://stackoverflow.com/questions/41711780
复制相似问题