gopiharan79
12 years agoOccasional Contributor
Mock REST Services to return JSON response
Hi,
I need to send a JSON response from a Mock REST Service for a GET request. I tried to set the response content type as follows in the OnRequestScript tab, still the response content type is rendered as text/plain instead of Json.
mockRunner.returnFile ( mockRequest.getHttpResponse(), new File (path)) // path is the file path of a text file with static Json Response.
def mockResult = new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult ( mockRequest )
mockResult.setResponseContentType("application/json") // This shows error message as dispatch error; missing response
mockResult.setContentType("application/json")
return mockResult
Tried this in AfterRequestScript tab as well, doesn't work.
mockRequest.getHttpResponse().setContentType("application/json")
Any help is highly appreciated.
Thanks,
Gopi.
I need to send a JSON response from a Mock REST Service for a GET request. I tried to set the response content type as follows in the OnRequestScript tab, still the response content type is rendered as text/plain instead of Json.
mockRunner.returnFile ( mockRequest.getHttpResponse(), new File (path)) // path is the file path of a text file with static Json Response.
def mockResult = new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult ( mockRequest )
mockResult.setResponseContentType("application/json") // This shows error message as dispatch error; missing response
mockResult.setContentType("application/json")
return mockResult
Tried this in AfterRequestScript tab as well, doesn't work.
mockRequest.getHttpResponse().setContentType("application/json")
Any help is highly appreciated.
Thanks,
Gopi.