cortez
12 years agoOccasional Contributor
[Resolved] REST mock service always returns 200 OK
Hi,
I'm new to SoapUI and although I'm generally finding it a joy to use I am having one small piece of frustration.
I am mocking a REST API and in the Mock Service editor I have a Groovy script for handling POST requests that looks like this:
So in the response I want the code to be "202 Accepted" and the Location header set to a new 'status update' (my API is asynchronous). Although I can successfully set the header, the request, when fired, always returns "200 OK".
Any ideas?
Thank you,
Christopher
I'm new to SoapUI and although I'm generally finding it a joy to use I am having one small piece of frustration.
I am mocking a REST API and in the Mock Service editor I have a Groovy script for handling POST requests that looks like this:
def responseFolder = "/path/to/docroot"
if ( mockRequest.method == "POST" )
{
mockRequest.httpResponse.setHeader("Location","http://localhost:8080/v1/foo/status/bf248efa-d951-4102-accf-bcd2a8804dc0")
mockRequest.httpResponse.setStatus(202, "Accepted")
mockRunner.returnFile(mockRequest.httpResponse, new File(responseFolder, "foo.json") )
return new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult(mockRequest)
}
So in the response I want the code to be "202 Accepted" and the Location header set to a new 'status update' (my API is asynchronous). Although I can successfully set the header, the request, when fired, always returns "200 OK".
Any ideas?
Thank you,
Christopher