I want to add referer value into my code but when i check it from network tab through inspect of Chrome, referer value is not constant, it's always changing. How can i catch and define it in my code ? Is there a way to set the referer as parameter in request header ?
I'm using RestAssure framework by using Java.
RestAssured.baseURI="https://test-v2-api.mykredit.com/api/customer/light";
//RestAssured.baseURI="https://test-v2-api.mykredit.com/api/membership";
RequestSpecification httpRequest2 = RestAssured.given();
JSONObject requestparam2 = new JSONObject();
System.out.println(mobilenum.substring(5));
requestparam2.put("pin",mobilenum.substring(5));
httpRequest2.header("Content-Type","application/json; charset=utf-8");
httpRequest2.body(requestparam2.toJSONString());
//Response response = httpRequest2.request(Method.POST,"/login");
Response response = httpRequest2.request(Method.POST,"/pinValidate");
String responseBody = response.getBody().asString();
System.out.println(responseBody);
int status = response.getStatusCode();
System.out.println("Status"+" "+status);
Assert.assertEquals(status, 200);
}
You can use
getHeader(String name)
method inio.restassured.response
(java documentation) to retrieve values from response headers.imports;
You can use the
header(String name)
method as well.UPDATE
You can use
getHeaders()
method inio.restassured.internal.RequestSpecificationImpl
(Java documentation) to retrieve request headers.imports;