Hello
I have looked at a similar titled post at Format server response on API call but it didn’t have the answers I was looking for.
I am creating an API on the KNIME server that will be called from different programs around my company e.g KNIME flow, a C# App, an Python App etc. One of the first thing I do is validate the input JSON which could look like this:
{
"Parameters":
{
"ReferenceNumber": "123456";
"Name":"Joe Blogs"
},
{
"SomeData":
{
"stuff": "to be or not to be",
"morestuff": "that is the question"
},
{
"otherData":
{
"evenmorestuff":"whether 'tis nobler in the mind"
}
}
If the ReferenceNumber is invalid I would like to send a response back a 411 status code with an error message of “ReferenceNumber is not valid”
If “otherData” is missing I would like to send a response back a 412 status code with an error message of “otherData is missing”
If the internal flow workings on the API fail (for example in a try catch) I would like to send a response back with a 500 number and a message.
Also I would like to strip out most, if not all, of the standard response body. example of the first part below
Is this possible?
Frank