{"id":17436396,"url":"https://github.com/vbilopav/verysimplerestclient","last_synced_at":"2025-09-02T21:37:53.298Z","repository":{"id":40769134,"uuid":"204198016","full_name":"vbilopav/VerySimpleRestClient","owner":"vbilopav","description":".NET Standard Very Simple REST client ~ My `HttpClient` abstraction","archived":false,"fork":false,"pushed_at":"2022-06-24T07:46:42.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T01:51:29.254Z","etag":null,"topics":["client","core","dotnet","http","rest"],"latest_commit_sha":null,"homepage":"","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/vbilopav.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":"2019-08-24T18:41:15.000Z","updated_at":"2022-06-24T07:46:33.000Z","dependencies_parsed_at":"2022-09-07T01:52:38.288Z","dependency_job_id":null,"html_url":"https://github.com/vbilopav/VerySimpleRestClient","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vbilopav/VerySimpleRestClient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbilopav%2FVerySimpleRestClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbilopav%2FVerySimpleRestClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbilopav%2FVerySimpleRestClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbilopav%2FVerySimpleRestClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vbilopav","download_url":"https://codeload.github.com/vbilopav/VerySimpleRestClient/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbilopav%2FVerySimpleRestClient/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263431754,"owners_count":23465543,"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","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":["client","core","dotnet","http","rest"],"created_at":"2024-10-17T10:09:30.317Z","updated_at":"2025-07-04T01:39:21.612Z","avatar_url":"https://github.com/vbilopav.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# VerySimpleRestClient\n\n.NET Standard Very Simple REST client ~ My `HttpClient` abstraction\n\n## What is it?\n\nLibrary for sending REST requests for .NET Standard based on `HttpClient`\n\n## But why? / Motivation\n\nBecause almost all .NET projects I've seen have some kind of `HttpClient` abstraction. \n\nBecause you probably just want to to send some REST/HTTP requests and get the response - not juggle multiple \ndisposable objects and multiple serializations and deserializations - you just one want one line of code that \nsends the request and read the response.\n\nAnd since `HttpClient` is quite big and complex interface - more often than not, it contained bugs, most commonly forgot to dispose some objects. It's challenging to get it right from first try.\n\nSo, this is mine solution that I'm using in various projects. I really don't wan't to write `HttpClient` helpers all over again, so hence this library. \n\n## Quickstart\n\n... is only way to start.\n\nJust install `VBSoftware.VerySimpleRestClient` NuGet package and add using directive `using VerySimpleRestClient;` or reference static classes directly. There are only two of them:\n\n- `SimpleClient` to get the response (from get or post or put or delete).\n- `Client` to get the response as well some ordinary http data like status code and stuff ...\n\nNo injection, no configuration, no nothing...\n\n## How can I use it?\n\nExamples:\n\nSend simple GET request:\n```csharp\nvar result = await SimpleClient.GetAsync(\"http://...\");\n// result is dynamic JObject\nAssert.Equal(\"value1\", result[\"key1\"]);\n```\n\nSend simple GET request and serialize JSON to a class:\n```csharp\nvar result = await SimpleClient.GetAsync\u003cMyResponse\u003e(\"http://...\");\n// result is MyResponse object\nAssert.Equal(\"value1\", result.Key1);\n```\n\nSend simple GET request and fetch usual additional data, such as status code, content type, etc...\n```csharp\nvar (result, response) = await Client.GetAsync(\"http://...\");\nAssert.Equal(HttpStatusCode.OK, response.StatusCode);\nAssert.Equal(\"text/plain; charset=utf-8\", response.ContentType);\n// ... etc, see source code for SimpleResponse: https://github.com/vbilopav/VerySimpleRestClient/blob/master/VerySimpleRestClient/SimpleResponse.cs\n```\n\nInlcude query string deserialized from object instance, anonymous object or dictionary:\n```csharp\nvar result = await SimpleClient.GetAsync(\"http://...\", new Query(new { key1 = \"value1\" }));\n```\n\nSend a POST request with JSON body serialized from object instance, anonymous object or dictionary: \n```csharp\nvar result = await SimpleClient.PostAsync(\"http://...\", body: new Json(new\n{\n    key1 = \"value1\", /* ... */\n}));\n```\n\nSend a POST request with multipart form body serialized from object instance, anonymous object or dictionary: \n```csharp\nvar result = await SimpleClient.PostAsync(\"http://...\", body: new Form(new\n{\n    key1 = \"value1\", /* ... */\n}));\n```\n\nSend a POST request with body in plain text format:\n```csharp\nvar result = await SimpleClient.PostAsync(\"http://...\", body: new TextPlain(\"The quick brown fox...\"));\n```\n\nSend a POST request with custom `HTTPContent` content in body:\n```csharp\nusing (var content = new HttpContent()) //replace HttpContent with non-abstract version\n{\n\tvar result = await SimpleClient.PostHttpContentAsync(\"http://...\", body: content);\n}\n```\n\nReuse same `HttpClient` for multiple requests:\n```csharp\nusing (var client = new HttpClient()) //replace HttpContent with non-abstract version\n{\n\t//\n\t// configure client additionally if neccessary, add Auth headers, etc ...\n\t//\n\tvar result1 = await SimpleClient.GetAsync(\"http://...\", client: client);\n\tvar result2 = await SimpleClient.PostAsync(\"http://...\", client: client);\n\tvar result3 = await SimpleClient.PutAsync(\"http://...\", client: client);\n\tvar result4 = await SimpleClient.DeleteAsync(\"http://...\", client: client);\n}\n```\n\n\n## Unit tests\n\nThere are none.\n\nHowever, this library is already used in multiple projects and in multiple unit tests already so it is very well tested \nand covered with other projects unit tests. Such as this for example: https://github.com/vbilopav/postgrest.net/tree/master/UnitTests\n\nThere might be transfer of those unit tests from other projects to this project, if need be - if need to change this library raises (which I highly doubt it will).\n\n## Licence\n\nCopyright (c) Vedran Bilopavlović.\nThis source code is licensed under the [MIT license](https://github.com/vbilopav/VerySimpleRestClient/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbilopav%2Fverysimplerestclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvbilopav%2Fverysimplerestclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbilopav%2Fverysimplerestclient/lists"}