5

I am building a REST API using ASP.NET Web API. I have a post request that may take more than 30s to complete. I resolved this by returning a 200 OK and a status attribute that can be polled by client app. If the status becomes "complete" the client can retrieve this result. But i am doing this mostly in any similar operation in the API.

I discovered the 102 HTTP Status Code that tells the client that the request is "Processing" and that it should wait for the complete response.

Questions : 1-What is your advice for using this approach ? 2-How to implement it in ASP.NET Web API using C#?

Edit: For more precise explanation i want to implement this sequence diagram on ASP.NET. Sequence Diagram To Implement

12
  • will you return the 102 immediately, or would you wait let's say 10 seconds on server-side and when your request thread detects that the operation is still running, end the request with the 102, cache the result on the server and wait for the client to send another request to fetch the result? Commented Sep 22, 2017 at 10:52
  • 2
    Sending back 102 should be the end of the request, it's up to the client to keep asking until they get a valid (e.g. 200) response. Commented Sep 22, 2017 at 11:00
  • 1
    @DavidG Yea, exactly there is no way for the client to wait for the same request. Commented Sep 22, 2017 at 11:03
  • 1
    @DiskJunky It is not a duplicate, i know how to return a specific status code. I am asking about the best way on how to do it. Commented Sep 22, 2017 at 11:05
  • 3
    related discussion on software engineering SE Commented Sep 22, 2017 at 11:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.