Search code examples
autodesk-forgerestsharphttp-status-codes

Get Thumbnail from FORGE API but received status code 202


I'm trying to get thumbnail from Forge API here

https://forge.autodesk.com/en/docs/model-derivative/v2/reference/http/thumbnails/urn-thumbnail-GET/ `

I got it with Postman and axios successfully, and I tried it with RestSharp, HttpClient and GetThumbnail from DerivativesApi (Autodesk.Forge) in C# but only got status code 202 with message:

{"Result":"The thumbnail generating for this graph node is pending"}

I realized that RestSharp and HttpClient only receive code 202 and return results. I don't know how I can wait for code 200 and thumbnail. Can anyone help me?

This is my code:

var request = new RestRequest($"https://developer.api.autodesk.com/modelderivative/v2/designdata/{nameHash}/thumbnail", Method.GET);
request.AddHeader("Authorization", $"Bearer {oauth.access_token}");
var client = new RestClient();
var restRes = client.Execute(request);

Solution

  • The 202 code typically indicates that the request has been accepted but the response is not available yet. Is it possible that you're asking for a thumbnail of a file that is still being processed by the Model Derivative service? Try inspecting the response headers, and see if there's one called x-ads-job-status which (according to the documentation) should tell you the status of the processing.