Git Product home page Git Product logo

api-client's People

Contributors

akrock avatar halforbit avatar jimnoble avatar ryanoshag avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ryanoshag akrock

api-client's Issues

Better Error Messages for Exceptions

Today when an unexpected HTTP response code is encountered, ApiClient throws an ApiRequestException.

While this exception is rich with properties about the request and the response, if the server includes a text response body (often containing an error message), this is not easily surfaced. A work-around today is to catch the ApiRequestException and use its Response to get the text content, but we can probably do better.

Also, Response contains an ErrorMessage property that is only populated under some circumstances, and particularly not when an unexpected response code is encountered.

On an unexpected response code, let's try to interrogate the response body (if there is one) as text, and include that text in both the Message property of the exception as well as the ErrorMessage property.

Add curl Command Property to Response

curl has a concise and widely adopted format for describing web requests. Not only can a curl command be run at the command prompt, but Postman allows importing curl commands for a rich experience.

If we could furnish developers with a curl command that precisely describes their request, they could easily reproduce the request with the tool of their choice.

Let's add a property to the Response type for retrieving a curl command.

This feature might need to be opt-in, since if there is a request body we will need to retain it fully in memory in some form to be able to include its content in the curl command.

HTTP 429 Should Be Retryable

Today HTTP 429 is not included in the default list of retryable status codes, but it should be. So let's add it.

Use IHttpClientFactory Instead of Directly Constructing HttpClient

This article outlines the motivations for the move:
https://learn.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests

Unfortunately, this is only supported in .NET Core 2.1+, so to retain backwards compatability, this will need to be switched off of target framework, with legacy .NET Framework 4.x continuing to use the existing pattern.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.