{"id":20227714,"url":"https://github.com/andreabbondanza/restclient","last_synced_at":"2025-09-22T04:32:05.167Z","repository":{"id":65413928,"uuid":"73324823","full_name":"andreabbondanza/RESTClient","owner":"andreabbondanza","description":"A simple library for .net core that can help you to consume REST services","archived":false,"fork":false,"pushed_at":"2018-10-30T13:09:24.000Z","size":81,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-09T00:43:04.430Z","etag":null,"topics":["aspnet-core","aspnetcore","cancellationtoken","dotnet","dotnet-core","dotnet-standard","dotnetstandard","httpclient","httpresponsemessage","rest-api","restclient","restrequest","restresponse"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreabbondanza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-09T22:01:53.000Z","updated_at":"2022-11-29T09:36:56.000Z","dependencies_parsed_at":"2023-01-22T09:45:14.686Z","dependency_job_id":null,"html_url":"https://github.com/andreabbondanza/RESTClient","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andreabbondanza/RESTClient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreabbondanza%2FRESTClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreabbondanza%2FRESTClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreabbondanza%2FRESTClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreabbondanza%2FRESTClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreabbondanza","download_url":"https://codeload.github.com/andreabbondanza/RESTClient/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreabbondanza%2FRESTClient/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276346835,"owners_count":25626522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-22T02:00:08.972Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnet-core","aspnetcore","cancellationtoken","dotnet","dotnet-core","dotnet-standard","dotnetstandard","httpclient","httpresponsemessage","rest-api","restclient","restrequest","restresponse"],"created_at":"2024-11-14T07:26:13.243Z","updated_at":"2025-09-22T04:32:04.892Z","avatar_url":"https://github.com/andreabbondanza.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RESTClient\nA simple library for .net core that can help you to consume REST services.\n\n:warning: BREAK CHANGE IN 4.0.0 - Now the __RESTRequest__ object is disposable \n\n## Objects\nWe have two object, RESTClient and RESTResponse that implements IRESTClient and IRESTResponse interfaces.\nWe have also extended the HttpClient object with Patch\\Head\\Options wrappers over the classic GetAsync\\PutAsync\\PostAsync, so we have a full REST Client methods support.\n\nPlease check inline docs for more information.\n\n## How to use\n\n#### Status Macrotypes\nRESTClient http status macrotypes:\n- 2xx : Succesful\n- 3xx : Redirected\n- 4xx : Error \n- 5xx : Fault \n\n### Methods\nPUT, GET, POST, PATCH, HEAD, OPTIONS\n\n\n### Interfaces\nThe library is based on three interfaces:\n- __IRESTClient__ : is the RESTClient core for connnections\n- __IRESTResponse__ : is the RESTResponse object\n- __IRESTRequest__ : is the RESTRequest object\n\nWith this approach you can use the dependency injection and use also your implementation of code.\n\n### Two way to approach\nYou can use the library creating and filling a RESTRequest object this way.\n\n- Instantiate a RESTRequest object\n- Set URL, Method, etc\n- Execute RESTClient.PerformRequest(myRESTRequestObject)\n\n\nEs: \n````C#\nvar apiHost = \"https://myapi.com/\";\nusing(RESTRequest request = new RESTRequest())\n{\n    request.SetMethod(Method.GET);\n    request.SetUrl(apiHost + \"2/categories\");\n    request.AddQueryArgs(\"order\", \"asc\");\n    request.AddHeader(\"Accept\", \"application/json\");\n    using(RESTClient client = new RESTClient())\n    {\n        using(RESTResponse response = (RESTResponse)await client.PerformRequest(request))\n        {\n            string myJson = null;\n            if(response.IsSuccesStatusCode())\n                myJson = response.ReadResponseAsStringAsync();\n            ...\n        }\n    }\n}\n````\n\nOr you can use directly RESTClient methods versions (PUT, GET, PATCH, ETC)\n\nEs: \n````C#\nvar apiHost = \"https://myapi.com/\";\nDictionary\u003cstring, string\u003e queryArgs = new Dictionary\u003cstring, string\u003e();\nqueryArgs.Add(\"order\", \"asc\");\nDictionary\u003cstring, string\u003e headers = new Dictionary\u003cstring, string\u003e();\nheaders.Add(\"Accept\", \"application/json\");\nusing(RESTClient client = new RESTClient())\n    using(RESTResponse response = (RESTResponse)await client.PerformGetRequestAsync(apiHost + \"2/categories\", queryAargs, headers))\n    {\n        string myJson = null;\n        if(response.IsSuccesStatusCode())\n            myJson = response.ReadResponseAsStringAsync();\n        ...\n    }\n}\n````\n\n## Types\n- __RESTResponse__ : The response object\n- __RESTClient__ : The client object\n- __RESTRequest__ : Request object\n\n### RESTResponse\n- __GetStatusCode()__ : _HttpStatusCode_ - Return the status code.\n- __IsSuccessStatusCode()__ : _bool_ - True if the type is Success\n- __IsRedirectedStatusCode()__ : _bool_ - True if type is Redirect\n- __IsErrorStatusCode()__ : _bool_ - True if type is Error\n- __IsFaultStatusCode()__ : _bool_ - True if type is Fault\n- __GetHttpStatusCodeType__ : _HttpStatusType_ - Return the status code type. If you want the status code you can use the enum in System.Net\n- __ReadResponseAsStringAsync__ : _awaitable Task\\\u003cstring\\\u003e_ - Return the response as a string\n- __GetResponse__ : _HttpResponseMessage_ - Get the direct response object\n- __RESTResponse(HttpResponseMessage)__ : _constructor_ - Construct a new RESTResponse object\n\n### RESTClient\n- __SetValidation(HeadersValidation)__ : _void_ - Set if the header must be validated before sending\n- __GetRESTResponse(HttpResponseMessage)__ : _IRESTResponse_ - Return a new RESTResèpmse object from the HttpResponseMessage\n- __IsValidUrl(string)__ : bool - Check if an url is valid\n- __GetHandler()__ : HttpClientHandler - _Get current http handler_\n- __SetHandler(HttpClientHandler)__ : Set a new handler for client. This will create also a new instance of httpclient in it\n- __RESTClient(CancellationToken)__ : _constructor_\n- __RESTClient(HeadersValidation, CancellationToken) : _constructor_\n- __RESTClient(HeaderValidatoin, HttpClientHandler, CancellationToken)__ : _constructor_\n- __RESTClient(HttpClientHandler, CancellationToken) : _constructor_\n- __PerformRequest(IRESTRequest)__ : _awaitable Task\\\u003cIRESTResponse\\\u003e_ - Perform a request by an IRESTRequest object\n- __PerformDeleteRequestAsync(string, Dictionary\\\u003cstring,string\\\u003e,Dictionary\\\u003cstring,string\\\u003e)__ : _awaitable Task\\\u003cIRESTResponse\\\u003e_ - Perform a delete request by an IRESTRequest object\n- __PerformPutRequestAsync(string, Dictionary\\\u003cstring,string\\\u003e,Dictionary\\\u003cstring,string\\\u003e)__ : _awaitable Task\\\u003cIRESTResponse\\\u003e_ - Perform a put request by an IRESTRequest object\n- __PerformPatchRequestAsync(string, Dictionary\\\u003cstring,string\\\u003e,Dictionary\\\u003cstring,string\\\u003e)__ : _awaitable Task\\\u003cIRESTResponse\\\u003e_ - Perform a patch request by an IRESTRequest object\n- __PerformPostRequestAsync(string, Dictionary\\\u003cstring,string\\\u003e,Dictionary\\\u003cstring,string\\\u003e)__ : _awaitable Task\\\u003cIRESTResponse\\\u003e_ - Perform a post request by an IRESTRequest object\n- __PerformGetRequestAsync(string, Dictionary\\\u003cstring,string\\\u003e,Dictionary\\\u003cstring,string\\\u003e)__ : _awaitable Task\\\u003cIRESTResponse\\\u003e_ - Perform a get request by an IRESTRequest object\n- __PerformHeadRequestAsync(string, Dictionary\\\u003cstring,string\\\u003e,Dictionary\\\u003cstring,string\\\u003e)__ : _awaitable Task\\\u003cIRESTResponse\\\u003e_ - Perform a head request by an IRESTRequest object\n- __PerformOptionsRequestAsync(string, Dictionary\\\u003cstring,string\\\u003e,Dictionary\\\u003cstring,string\\\u003e)__ : _awaitable Task\\\u003cIRESTResponse\\\u003e_ - Perform a options request by an IRESTRequest object      \n\n### RESTRequest\n- __SetContent(HttpContent)__ : _void_ - Add a content to the request\n- __SetHeader(string,string)__ : _void_ - Add new header to the request\n- __SetQueryArgs(string,string)__ : _void_ - Add a new argoument to the query string\n- __SetUrl(string)__ : _void_ - Set the url to the request\n- __IsValidUrl(string)__ : bool - Check if an url is valid\n- __GetMethod()__ : _Method_ - return the current method\n- __SetMethod(Method)__ : _void_ - return the current method\n- __GetHeaders()__ : _Dictionary\\\u003cstring,string\\\u003e_ - Return the setted headers\n- __GetContent()__ : _HttpContent_ - Return the setted content\n- __GetQueryArgs()__ : _Dictionary\\\u003cstring,string\\\u003e_ - Return the setted headers\n- __GetUrl()__ : _string_ - Return the request URL\n- __AddMultipartFormDataContent(string,byte[],string)__ : _void_ - Add a multipart form data\n- __AddMultipartFormDataContent(string,string)__ : _void_ - Add a multipart form data\n- __AddMultipartFormDataContent(string,Stream,string)__ : _void_ - Add a multipart form data\n- __AddFormUrlEncodedContent(string,string)__ : _void_ - Add a form url encoded data\n- __Dispose()__ : _void_\n- __RESTRequest(string)__ : _constructor_ - Construct a RESTRequest with url\n- __RESTRequest()__ : _constructor_ \n\n## Note\n\n:warning: BREAK CHANGE IN 4.0.0 - Now the __RESTRequest__ object is disposable \n\n## NuGet\nYou can find it on nuget with the name [DewRESTClient](https://www.nuget.org/packages/DewRESTClientStandard/)\n\n## About\n[Andrea Vincenzo Abbondanza](http://www.andrewdev.eu)\n\n## Donate\n[Help me to grow up, if you want](https://payPal.me/andreabbondanza)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreabbondanza%2Frestclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreabbondanza%2Frestclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreabbondanza%2Frestclient/lists"}