0

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);
RomCoca
  • 23
  • 4

1 Answers1

0

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.

Petr Broz
  • 8,891
  • 2
  • 15
  • 24
  • I understand, but I don't know how to download the data after it's done – RomCoca Oct 28 '22 at 09:45
  • As I mentioned already, the 202 code indicates that the response is not available **yet** so when you repeat the request later, it should eventually return 200 OK with the content you want. – Petr Broz Oct 31 '22 at 14:36
  • 1
    Thank Petr Broz, I put it in a loop to get the code 200, and it worked – RomCoca Nov 15 '22 at 09:40