Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Return http status code 201 from a service #5202


User avatar
0
rattlehub created

Take the method protected virtual async Task CreateUserAsync(CreateOrUpdateUserInput input)

This returns 200. Is it possible without creating a controller in a service inheriting from ApplicationService to return 201 instead of 200. The services don't follow the correct http status codes as defined here. <a class="postlink" href="http://www.restapitutorial.com/httpstatuscodes.html">http://www.restapitutorial.com/httpstatuscodes.html</a>


2 Answer(s)
  • User Avatar
    0
    rattlehub created

    Method is purely an example. I want to return 201 for create for angular client without creating a controller

  • User Avatar
    0
    alper created
    Support Team

    hi,

    you cannot set a status code from an application service because it's a web layer feature. you need to write your own controller #3580@ac71af71-6264-42c2-8f33-67145942f177