HttpResponseException:内部服务器错误

时间:2016-10-05 03:25:08

标签: rest groovy

我曾经见过的最奇怪的事情。我通过Postman运行我的API调用,并且在发出GET请求时没有任何问题。但是,下面的groovy代码会拉groovyx.net.http.HttpResponseException: Internal Server Error。我无法调整甚至调试,以了解我是否实际上收到了5xx错误或我的代码被合法地破坏了。

此外,我过去曾经使用过像这样的代码,我重新提取了该代码并且出现了相同的错误。好奇我的Maven配置设置是否也会导致问题(不确定我需要调试的位置)。我还尝试弄乱了URIbuilder行,看看更改端点是否有帮助。

感谢您的帮助

abstract class HTTTPClient {

protected runGetRequest(String endpointPassedIn, RESTClient Client){

    URIBuilder myEndpoint = new URIBuilder(new URI(Client.uri.toString() + endpointPassedIn))
    //Error happens at the next Line
    Client.get(uri: myEndpoint, contentType: ContentType.JSON)
    LazyMap Response = unprocessedResponse.getData() as LazyMap
    return Response
    }
}




@Singleton(lazy = true)
class RequestService extends HTTTPClient {

private String auth = "myAuth"
private String baseURL = 'https://api.endpoint.net/'

private RESTClient client = setClient(baseURL, auth)

public buildResponseList(int pagesToPull) {
    String endpoint = 'site/address.json?page='
    ArrayList responseList = []
    for (int i = 1; i <= pagesToPull; i++) {
        LazyMap Response = runGetRequest(endpoint + i, client)
        for (row in Response) {
            responseList.add(row)
            //TODO Add in items call here
        }
    }
    return conversationList
}

1 个答案:

答案 0 :(得分:0)

错误是由于授权中的编码,是在服务器端,而不是代码端