locked
Return HTTP status codes without using an API Controller RRS feed

  • Question

  • User-1188570427 posted

    Hello,

    I have a library API that is not a restful web API.

    Can I still throw HttpResponseMessage error codes even though my API isn't a web API?

    Basically it is just a class library and not set up as a Restful API. 

    Tuesday, June 16, 2020 1:04 PM

All replies

  • User475983607 posted

    I have a library API that is not a restful web API.

    Can I still throw HttpResponseMessage error codes even though my API isn't a web API?

    Basically it is just a class library and not set up as a Restful API. 

    IMHO, Your question makes no logical sense.   HTTP (REST) is message protocol.  If your are not using HTTP then I do not see any reason to use HttpResponseMessage.  Can you explain the problem you are trying to solve that the standard try...catch blocks does not handle?

    However, there is nothing stopping you from populating the HttpResponseMessage class and returning the instance to a caller.  The caller will need to read the status code.  

    Tuesday, June 16, 2020 1:33 PM