If my request is POST with "Prefer":"respond-async", Shall I still check response code 202? Or it is always either 200 or some 4XX code. This is comparing with GET status, you many keep GET until you get 200 code back.
If my request is POST with "Prefer":"respond-async", Shall I still check response code 202? Or it is always either 200 or some 4XX code. This is comparing with GET status, you many keep GET until you get 200 code back.
Hello @jim.yu
The overview steps to process async post request are listed below:
1.send Post request
2.check the response code:
2.1 200 => get the result.
2.2 other code which is not 200 or 202 => get the error.
2.2 202 => means the result is not ready. Then, extract the location URL in the response headers. Next, execute Get command with the location URL to check the status of the Post request till the response code is not 202 which means the Post request is proceeded completely.
- if the response code is 200 => get the result
- Other code => get the error
For more detail of Async, please refer to Async Key Mechanism
@jim.yu, to complete Pimchaya's response, you might also want to look at the On Demand extraction workflow description in REST API Tutorial 3.
To get token, we use post with async. The tutorial code just checks if the status code is 200 and treats all other codes as an error. I mean in extreme condition, is it possible a 202 code will return and the above steps have to be followed.
Is it more precise that we get token in sync mode in this case? Or can someone from server side confirm that get token is in deed a synced request even preferred is async. In my question, I stated 'extreme condition' such as requests are piled up on server side.
According to the Async key mechanism, methods that support asynchronous requests are annotated with the "Org.OData.Capabilities.V1.AsynchronousRequestsSupported" and a value of "true" in the metadata.
The metadata of "RequestToken" does not have the "AsynchronousRequestsSupported" defined, so this method should support only synced request.