I have a get rest api, which will return a list of objects in json format
What is best practice for return type of a rest api?
Which one should I use? Thanks
public HttpResponseMessage MyGetMethod(int acctId, string userId)
public HttpMyObjectResponse MyGetMethod(int acctId, string userId)
HttpResponseMessage is better because you can do things like set the status code, add additional headers, etc. in the response.
userId that was passed in doesn't exist. Then you could do something like
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "That user does not exist");