Autodesk-Forge / forge-api-dotnet-core

Forge Core .NET SDK: Provides shared .NET features used by other SDKs
https://www.nuget.org/packages/Autodesk.Forge.Core
Apache License 2.0
13 stars 12 forks source link

HttpRequestException.StatusCode is not set #70

Closed provegard closed 3 years ago

provegard commented 3 years ago

The EnsureSuccessStatusCodeAsync method doesn't set HttpRequestException.StatusCode:

https://github.com/Autodesk-Forge/forge-api-dotnet-core/blob/main/src/Autodesk.Forge.Core/HttpResponseMessageExtensions.cs#L41

The current workaround is to check if the message contains "status code N".

zhuliice commented 3 years ago

@provegard thanks for reporting. We will migrate this project to .Net 5 first and fix this issue

provegard commented 3 years ago

Sounds good! I assume Autodesk.Forge and Autodesk.Forge.DesignAutomation will be migrated to .NET 5 as well? I use them both from a .NET 5 project, and while there are a lot of build/restore warnings, they work just fine.

provegard commented 3 years ago

By the way, if the error is 429 (too many requests), I'd like to read the Retry-After header, so it would be useful to have headers in the exception (or at least the Retry-After time).

zhuliice commented 3 years ago

Sounds good! I assume Autodesk.Forge and Autodesk.Forge.DesignAutomation will be migrated to .NET 5 as well?

That is right.

if the error is 429 (too many requests), I'd like to read the Retry-After header, so it would be useful to have headers in the exception (or at least the Retry-After time)

We will see what we can do for it

zhuliice commented 3 years ago

@provegard, the requests have been done by https://github.com/Autodesk-Forge/forge-api-dotnet-core/pull/71 and https://github.com/Autodesk-Forge/forge-api-dotnet-core/pull/72. The changes are released with version of 2.0.1 (Autodesk.Forge.Core)

zhuliice commented 3 years ago

I am closing this issue. Please let us know if you have any question.