Hello everyone,
Using WebDev, I’ve to respond to a callback and the server accept only a code 204 No Content as a response. It seems that webdev answer 200 by default if there is nothing return.
How can I do that?
Many thanks
You should be able to do it directly with the servletResponse from the request, hinted at in the manual. You must return None
to prevent normal handling of a webdev dictionary response.
Something like this:
response = request['servletResponse']
response.status = 204
return None
5 Likes
Hi,
Thanks, that’s perfect.
For those encountering this post in 2025, like I am now:
It seems returning a dict does work.
Here I changed the code to 302 and returned a dict:
endpoint's code for reference
def doGet(request, session):
tag_paths = [
"[System]Gateway/Redundancy/IsMaster",
"[System]Gateway/Redundancy/IsActive"
]
is_master, is_active = [qv.value for qv in system.tag.readBlocking(tag_paths)]
if not is_active:
request['servletResponse'].status = 302
return {
'json': {
'is_master': is_master,
'ip_addr': system.net.getIpAddress(),
'hostname': system.net.getHostName()
}
}
3 Likes