bkbn16
9 years agoContributor
Need to update/set Header Values through groovy scripting
Hi,
I have created a REST Mock response. To invoke the response; I have the URI and request body.
def Accept = mockRequest.getRequest().getHeader("Accept")
log.info(Accept)
This is giving me /* as response in console, but I need to update it as "application/json"
def Method = mockRequest.getRequest()
log.info(Method)
This is giving me ...
POST rest/login
Accept: /*
Content-Type: application/json
Content-Length: 8
......
But what I want is along with the request body like
POST rest/login
Accept: application/json
Content-Type: application/json
Content-Length: [length of this message]
{'username':'admin', 'password': 'admin'}
How can I update or set the request header and the body through the script ?