Forum Discussion

eduardocasino's avatar
eduardocasino
New Contributor
8 years ago
Solved

OnRequest script causes mock service to fail with 500 Internal Server Error

Hi, I'm creating a REST mock service which supports just a few methods and I want the service to return a 405 Method Not Allowed whenever an unsupported method is invoked. So, I've created mock actio...
  • eduardocasino's avatar
    8 years ago

    I'll answer myself, this is the correct code:

     

    if ( mockRequest.httpRequest.method != "GET" && mockRequest.httpRequest.method != "POST" )
    {
    	
    	mockRequest.httpResponse.status = 405
    
    	return new com.eviware.soapui.impl.rest.mock.RestMockResult( mockRequest )
    
    }