forge-api-dotnet-client icon indicating copy to clipboard operation
forge-api-dotnet-client copied to clipboard

Using SDK and Deserialization Exceptions

Open davidyardy opened this issue 3 years ago • 0 comments

I am follow code sample on https://github.com/Autodesk-Forge/forge-api-dotnet-client/blob/master/docs/DerivativesApi.md#getmetadata

  try
            {
                Metadata result = apiInstance.GetMetadata(urn, acceptEncoding);
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling DerivativesApi.GetMetadata: " + e.Message );
            }

I am getting exception about unable to convert to Metadata (deserilization).

It looks like I need to modify to this to avoid this error/exception.

          Autodesk.Forge.Model.DynamicJsonResponse result = await apiInstance.GetMetadataAsync(urn, acceptEncoding);
           Metadata m = result.ToObject<Metadata>();

Now I can get the Metadata result. Can you confirm this is correct?

davidyardy avatar Jan 25 '23 18:01 davidyardy