groovyx.net.http.ResponseParseException 从 Spock groovy 调用 Web 服务时。邮递员或其他客户工作正常

groovyx.net.http.ResponseParseException while invoking web service from Spock groovy. Works fine from Postman or other clients

我想使用网络服务并向其响应添加断言。我收到以下异常:

groovyx.net.http.ResponseParseException: 
    at groovyx.net.http.HTTPBuilder.handleResponse(HTTPBuilder.java:495)
    ......
    at Subscription.Order Products(Subscription.groovy:14)
Caused by: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object

The current character read is 'I' with an int value of 73
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
Invalid UTF-8 middle byte 0x52

我的操作如下:

  def setupSpec() {
            client = new RESTClient("http://tsi-services-dev2.canaldigital.com:9080/test/webgw-dealer/v1/");
            client.handler.failure = { resp, data -> return resp }
        }
///// orderProductPayload is a variable which has an input
    def "Order Products"() {
            when:
            def resp = client.post(path: "order/orderProduct", requestContentType: JSON, contentType: JSON, body: orderProductPayload) as HttpResponseDecorator
            then:
            println("response: " + resp.data)
            resp.status == successResponseStatus
        }

我还有其他这样的测试,它们工作正常,并且这个输入有效负载的特定测试在 Postman 中工作正常

这是我对在 spock/groovy 中失败的此操作的回复 header:

Content-Length →159
Content-Type →application/json
Date →Wed, 05 Apr 2017 06:19:16 GMT
X-Correlation-ID → xxxxx

响应 header 另一个有效的操作:

  Connection →close
    Content-Length →273
    Content-Type →application/json
    Date →Wed, 05 Apr 2017 06:16:41 GMT
    X-Correlation-ID → xxxxx

非常感谢您的帮助,结果发现在我的请求中有一个特殊字符,例如服务不喜欢的 Ø,因此以这种荒谬的方式响应。现在工作正常