How to return only a status code to a POST request in a service program Instead of an HTML page

created a REST service using servicestack, and in post request I have a return object as follows

  return new HttpResult(request)
                {
                    StatusCode = HttpStatusCode.Created,

                };

request: the object that I posted to the database

servicestack post request

When I check it in the violinist, it displays the whole HTML page of the utility program in the response body, instead I would like to return only the status code, so please tell me how can I do this?

thank

+5
source share
1 answer

There was a bug in versions before <v3.05, which did not take into account the HttpResult ContentType in some scenarios, now it should be fixed with the latest version of ServiceStack on NuGet or available from:

https://github.com/ServiceStack/ServiceStack/downloads

ContentType, Accept: application/json HttpClient ? format = json URL.

, DTO, HttpResult:

return new HttpResult() { StatusCode = HttpStatusCode.Created };

, Html-, ( Rest Client, : text/html). ContentType , (, JSON/JSV), , :

return new HttpResult() { 
    StatusCode = HttpStatusCode.Created,
    ContentType = ContentType.Json
};
+5

All Articles