What do you think should be the optimal design pattern for long-task resource create/update using a Polling-Task strategy?
Example of Create:
POST https://api.contoso.com/v1.0/products HTTP/1.1
Accept: application/json
{
"color": "blue"
}
HTTP/1.1 202 Accepted
Operation-Location: https://api.contoso.com/v1.0/operations/123
GET https://api.contoso.com/v1.0/operations/123
Accept: application/json
HTTP/1.1 200 OK
{
"created_datetime": "2022-06-19T12-01-03.4Z",
"status": "processing"
}
GET https://api.contoso.com/v1.0/operations/123
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
{
"created_datetime": "2022-06-19T12-01-03.45Z",
"updated_datetime": "2022-06-19T12-06-03.0024Z",
"status": "succeeded",
"resource_location": "https://api.contoso.com/v1.0/products/556131"
}
GET https://api.contoso.com/v1.0/products/556131
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 556131,
"color": "blue"
}
Using POST for resource creation seems fine to me, but for the resource update, is it ok to use PUT for async ops?
PUT https://api.contoso.com/v1.0/products/556131 HTTP/1.1
Accept: application/json
{
"color": "red"
}
HTTP/1.1 202 Accepted
Operation-Location: https://api.contoso.com/v1.0/operations/124
...
btw, I'm following this guideline: https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#example-of-the-typical-flow-polling