当我发送请求时,它总是返回状态代码 200 但响应是直接到登录页面而不是我的请求的值。
这是我的手动脚本:
String mycookie = GlobalVariable.myToken
String mycsrf = GlobalVariable.mycsrf
String callfullurl = server+thepathURR+param
String authHeader = ""
TestObjectProperty header1 = new TestObjectProperty("Cookie", ConditionType.EQUALS, mycookie)
TestObjectProperty header2 = new TestObjectProperty("Content-Type", ConditionType.EQUALS, "application/json")
TestObjectProperty header3 = new TestObjectProperty("Accept", ConditionType.EQUALS, "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
ArrayList defaultHeaders = Arrays.asList(header1, header2, header3)
RequestObject ro = new RequestObject()
ro.setRestUrl(callfullurl)
ro.setFollowRedirects(true)
ro.setHttpHeaderProperties(defaultHeaders)
ro.setRestRequestMethod(method)
def respObj = WS.sendRequest(ro)
'Get the response of requested Ajax'
String response = respObj.getResponseText()
'Get the response status'
def chkcode = respObj.getStatusCode()