dimanche 20 août 2017

Correct HTTP Response when resource changed

I'm implementing REST web API with .NET CORE. One of the action I have in my WEB API is updating location of specific user..

[HttpPut("{userName:username}/{regionName:regionname}", Name = "UpdateUser")]
    public async Task<IActionResult> UpdateUser([FromRoute][Required]string userName, [FromRoute][Required]string regionName, [FromBody][Required]UpdateUserViewModel user)
    { 
         //..some code here
    }

i.e. when this operation will be finished, the location of this resource will be changed, so if my request in the beginning was:

Request1: PUT "localhost:5000/controller/usernamehere/location1" and it was updated with "location2"

After Request1 ends, new location will be Request2: PUT"localhost:5000/controller/usernamehere/location2" and location in Request1 will be irrelevant.

My question is : What is the best practice for response (status code, location) to be returned in this case?

Thanks!




Aucun commentaire:

Enregistrer un commentaire