How to define response with no content? #263
-
I think I may be missing something here in my understanding. But how do I define an endpoint which does not return any content? We have a PUT endpoint that returns 204 NoContent response if it is successful. It can also return a 400 BadRequest if validation fails. And also 404 NotFound is returned if unable to match the given identifiers. In the consuming code, all of these matters to decide the next flow o things. But the generic Response expects a type of response object and I don't think there is any non-generic Response object I can use, so the below does not work.
I guess my question is, what should my return type should be if there is no content coming back on success? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Thinking about this further I guess I could use following
But I am not sure if this is the correct usage. I ended up simplifying my code so that I do not have to know the reason of the failure. So now it reads, but I would still like to know how to get the response status code if needed without specifying string as return type, or is string return type appropriate?
|
Beta Was this translation helpful? Give feedback.
you don't need the Response part, just
Task<HttpResponseMessage>
is good enough