We use custom query handlers in MAIN:/project/exec/globals/serverinterface/queryhandlers to interact with our models via FlexSim Webserver, as documented in https://docs.flexsim.com/en/24.0/Reference/DeveloperAdvancedUser/Webserver/Webserver.html#InstanceQueries
What I noticed is that queryinstance always responds with HTTP status code 200 OK, and there doesn't seem a way to set a different status. In particular I'd like to be able to reply with 400 Bad Request or 404 Not Found.
I noticed than many default queryhandlers use this or similar code:
setnodestr(replyNode, "HTTP/1.1 404 Not Found"); return replyNode;
However, if I try to do the same and set replyNode to be the header of the response, it still ends up as the body of the response with a status 200.
For instance, this HTTP request
http://127.0.0.1:10001/webserver.dll?queryinstance=TestModel&instancenum=1&getnodedata=doesnotexist
results in a response with HTTP status code 200 and the body fakes to be an HTTP response:
So the question is, what is the correct way to set HTTP status code from the instance query handler?
FlexSim 24.0.2