Web Connection User Discussions
REST - how to handle bad requests
Hi, I have a REST service with around 30 methods/services defined (WestWindWeb ver 6.05). How to handle requests which are not defined ? EXAMPLE: https://mydomain.com/WestWindService/login.ws works because I have a Function Login defined. If I manually type URL like: https://mydomain.com/WestWindService/somethingUndefined.ws it will crash the REST Server.
Server shows error "Property somethingUndefined.ws not found" and needs manual restart - something I want to avoid... I'd like to catch that before it hits rest process...
Hi Adam,
You could put something like this in the OnProcessInit()
method...
lcFunction = JUSTSTEM(Request.GetPhysicalPath())
IF !PEMSTATUS(THIS,lcFunction,5)
* call or redirect to a method that returns an error response
RETURN .F.
ENDIF
Carl