{"id":14980370,"url":"https://github.com/nstevens1040/execute.httprequest","last_synced_at":"2025-07-28T02:03:23.108Z","repository":{"id":54287170,"uuid":"329168602","full_name":"nstevens1040/Execute.HttpRequest","owner":"nstevens1040","description":".NET Framework class library used the send HTTP requests and parse the response.","archived":false,"fork":false,"pushed_at":"2024-10-22T15:14:27.000Z","size":23518,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T20:11:24.779Z","etag":null,"topics":["class-library","cookies","csharp","dotnet-framework","http","http-client","http-delete","http-get","http-post","http-request","http-response","http-trace","https","windows-powershell"],"latest_commit_sha":null,"homepage":"https://nstevens1040.github.io/Execute.HttpRequest/","language":"HTML","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/nstevens1040.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"nstevens1040","ko_fi":"nstevens1040","liberapay":"nstevens1040","patreon":"nstevens1040","custom":"https://paypal.me/nstevens312"}},"created_at":"2021-01-13T02:17:45.000Z","updated_at":"2024-10-22T15:13:04.000Z","dependencies_parsed_at":"2024-09-05T19:19:52.074Z","dependency_job_id":"f0079ab3-0cb1-4379-8fb9-44c5a3b81adf","html_url":"https://github.com/nstevens1040/Execute.HttpRequest","commit_stats":{"total_commits":181,"total_committers":2,"mean_commits":90.5,"dds":0.09392265193370164,"last_synced_commit":"16d4f54c03be93fe6294a19297603d74a42ccd0f"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstevens1040%2FExecute.HttpRequest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstevens1040%2FExecute.HttpRequest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstevens1040%2FExecute.HttpRequest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nstevens1040%2FExecute.HttpRequest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nstevens1040","download_url":"https://codeload.github.com/nstevens1040/Execute.HttpRequest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238743886,"owners_count":19523195,"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":["class-library","cookies","csharp","dotnet-framework","http","http-client","http-delete","http-get","http-post","http-request","http-response","http-trace","https","windows-powershell"],"created_at":"2024-09-24T14:01:40.283Z","updated_at":"2025-02-13T22:31:32.430Z","avatar_url":"https://github.com/nstevens1040.png","language":"HTML","readme":"[![Build status](https://ci.appveyor.com/api/projects/status/github/nstevens1040/Execute.HttpRequest?branch=master\u0026svg=true)](https://ci.appveyor.com/project/nstevens1040/execute-httprequest-scamo)\n[![codecov](https://codecov.io/gh/nstevens1040/Execute.HttpRequest/branch/master/graph/badge.svg?token=M9gp01ySOr)](https://codecov.io/gh/nstevens1040/Execute.HttpRequest)\n[![MIT License](https://img.shields.io/badge/license-MIT%20License-yellow)](https://github.com/nstevens1040/Execute.HttpRequest/blob/master/LICENSE)\n[![Ko-Fi](https://img.shields.io/badge/donate-ko--fi-9cf?logo=ko-fi)](https://ko-fi.com/M4M23DLL6)\n[![PayPal](https://img.shields.io/badge/donate-paypal-blue?logo=paypal)](https://paypal.me/nstevens312)\n[![Bitcoin](https://img.shields.io/badge/donate-bitcoin-orange?logo=bitcoin)](https://nstevens1040.github.io/donthatedonate/)\n[![Monero](https://img.shields.io/badge/donate-monero-red?logo=monero)](https://nstevens1040.github.io/sparesomechange/)\n# Execute.HttpRequest\n[View the html version of this README](https://nstevens1040.github.io/Execute.HttpRequest)  \n.NET Framework class library used the send HTTP requests and parse the response.  \nThis library uses [my fork](https://github.com/nstevens1040/AngleSharp.DOMParser) of [AngleSharp](https://github.com/AngleSharp/AngleSharp) to parse HTML strings into a document object model.  \n# Installation  \n## Quick Start  \nMake Execute.HttpRequest available in your current Windows PowerShell session using the script below.  \n```ps1\n[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12\niex (irm (irm \"https://api.github.com/repos/nstevens1040/Execute.HttpRequest/releases/latest\").assets[0].browser_download_url)\n```  \n  \n\u003cimg height=188 width=800 src=\"https://raw.githubusercontent.com/nstevens1040/Execute.HttpRequest/master/.ignore/xhr.gif\"/\u003e  \n  \nTest it.  \n```ps1\n$r = [Execute.HttpRequest]::Send(\"https://nstevens1040.github.io/Execute.HttpRequest/\")\n$r.ResponseText\n```  \nThis should output the response text from nstevens1040.github.io/Execute.HttpRequest.  \n  \n\u003cimg height=436 width=800 src=\"https://raw.githubusercontent.com/nstevens1040/Execute.HttpRequest/master/.ignore/render1623185483992.gif\"/\u003e  \n    \n## .NET Framework project in Visual Studio    \nClone the repository and build it in Visual Studio. It will create the library file, **Execute.HttpRequest.dll** in `.\\source\\repos\\Execute.HttpRequest\\Execute.HttpRequest\\bin\\Debug\\Execute.HttpRequest.dll`.  \nMake a reference to **Execute.HttpRequest.dll** and use the **Send** method:  \n```cs\nusing Execute;\nusing System;\nusing System.Net;\nusing System.Collections.Specialized;\nusing System.Net.Http;\nnamespace JustAnExample\n{\n    public class Test\n    {\n        public RetObject Request(CookieCollection cookies, OrderedDictionary headers)\n        {\n            RetObject response = HttpRequest.Send(\n                \"https://fakedomain.com/post\",\n                HttpMethod.Post,\n                headers,\n                cookies,\n                \"application/x-www-form-urlencoded\",\n                \"data=that\u0026i%27m=sending\u0026via=httpost\"\n            );\n            return response;\n        }\n    }\n}\n```  \n## Windows PowerShell 5.1  \n### Add-Type using the path to the DLL  \nClone the repository and build it in Visual Studio. It will create the library file, **Execute.HttpRequest.dll** in `.\\source\\repos\\Execute.HttpRequest\\Execute.HttpRequest\\bin\\Debug\\Execute.HttpRequest.dll`.  \nNow you can use the **Path** parameter, specifying the path to the DLL file as the parameter to Add-Type instead of TypeDefinition.  \n```ps1\nAdd-Type -Path .\\source\\repos\\Execute.HttpRequest\\Execute.HttpRequest\\bin\\Debug\\Execute.HttpRequest.dll\n```  \nOnce the command completes, you can use the library in PowerShell like this:\n```ps1\n$re = [Execute.HttpRequest]::Send(\n    \"https://fakedomain.com/post\",\n    [System.Net.Http.HttpMethod]::Post,\n    ([ordered]@{\"x-csrf-token\"=\"blahblahblahfaketokenblahblah\"}),\n    $cookies, # CookieContainer example below\n    \"application/x-www-form-urlencoded\",\n    \"data=that\u0026i%27m=sending\u0026via=httpost\"\n)\n```  \n# Usage  \n## Positional parameters:  \n### Uri  \n|                |                                                         |\n|----------------|---------------------------------------------------------|\n| **Type**       |   System.String                                         |\n| **Position**   |   0                                                     |\n| **Purpose**    |   The full URI to the resource you are requesting.      |\n| **Required?**  |   Yes                                                   |  \n  \n```cs\nstring uri = @\"https://twitter.com/sessions\";\n```  \n### Method  \n|                |                                                     |\n|----------------|-----------------------------------------------------|\n| **Type**       |   System.Net.Http.HttpMethod                        |\n| **Position**   |   1                                                 |\n| **Purpose**    |   The HTTP method you're using to send the request. Must be one of **GET, POST, PUT, DELETE, TRACE, OPTIONS, or HEAD**. |\n| **Required?**  |   No (**Defaults to GET** if not specified)         |  \n```cs\nHttpMethod method = HttpMethod.Post;\n```  \n### Headers  \n|                |                                                     |\n|----------------|-----------------------------------------------------|\n| **Type**       |   System.Collections.Specialized.OrderedDictionary  |\n| **Position**   |   2                                                 |\n| **Purpose**    |   Http headers (**not Content-\\***) to send along with the HTTP request. |\n| **Required?**  |   No (**HTTP headers Path, User-Agent, and Content-Length are sent automatically**)       |  \n```cs\nOrderedDictionary headers = new OrderedDictionary();\nheaders.Add(\"x-csrf-token\",\"blahblahblahfaketokenblahblah\");\n```  \n### Cookies  \n|                |                                                     |\n|----------------|-----------------------------------------------------|\n| **Type**       |   System.Net.CookieCollection                       |\n| **Position**   |   3                                                 |\n| **Purpose**    |   CookieCollection object populated with 1 or more System.Net.Cookie objects to send along with the HTTP request. |\n| **Required?**  |   No                                                |  \n```cs\nCookieCollection cookies = new CookieCollection();\ncookies.Add((new Cookie(){\n    Name=\"MyCookieName\",\n    Value=\"MyCookieValue\",\n    Path=\"/\",\n    Domain=\".fakedomain.com\",\n    Expires=DateTime.Now.AddDays(365)\n}));\n```  \n### Content-Type  \n|                |                                                 |\n|----------------|-------------------------------------------------|\n| **Type**       |   System.String                                 |\n| **Position**   |   4                                             |\n| **Purpose**    |   Mimetype string to include if you're sending data along with your HTTP request. |\n| **Required?**  |   No                                            |  \n```cs\nstring contentType = @\"application/x-www-form-urlencoded\";\n```  \n### Body  \n|                |                                                 |\n|----------------|-------------------------------------------------|\n| **Type**       |   System.String                                 |\n| **Position**   |   5                                             |\n| **Purpose**    |   Data that you're sending along with your HTTP request. **HTTP method must be either POST or PUT.** |\n| **Required?**  |   No                                            |  \n```cs\nstring body = @\"Any=string\u0026will=do%2c\u0026so=long\u0026as=it\u0026serves=your\u0026purpose=well\";\n```  \n### FilePath  \n|                |                                                 |\n|----------------|-------------------------------------------------|\n| **Type**       |   System.String                                 |\n| **Position**   |   6                                             |\n| **Purpose**    |   If you're sending a file along with a multipart/form-data POST request, then specify the path to the file you are sending here. |\n| **Required?**  |   No                                            |  \n```cs\nstring filepath = Environment.GetEnvironmentVariable(@\"userprofile\") + \"\\\\file.txt\";\n```  \n\n## Return object  \nThe Send method returns and instance of an object with the typename **Execute.RetObject**.  \nThe object contains 5 properties:  \n\n| Name                     |  Type                                              |  Description                                               |\n|--------------------------|----------------------------------------------------|------------------------------------------------------------|\n| **CookieCollection**     |  System.Net.CookieCollection                       |  Cookies returned from HTTP request                        |\n| **HtmlDocument**         |  System.Object                                     |  HTML document parsed via AngleSharp.Html.Dom.HtmlDocument |\n| **HttpResponseHeaders**  |  System.Collections.Specialized.OrderedDictionary  |  Headers returned from HTTP request                        |\n| **HttpResponseMessage**  |  System.Net.Http.HttpResponseMessage               |  Initial object returned from HttpClient.SendAsync()       | \n| **ResponseText**         |  System.String                                     |  Text body of the HTTP response                            |  \n  \nThe advantage of using this library is the ability to take, for example, the CookieCollection object returned from one request and pipe those cookies into the next request.  \nTo illustrate:  \n```ps1\n$re = [Execute.HttpRequest]::Send(\n    \"https://fakedomain.com/post\",\n    [System.Net.Http.HttpMethod]::Post,\n    ([ordered]@{\"x-csrf-token\"=\"blahblahblahfaketokenblahblah\"}),\n    $cookies,\n    \"application/x-www-form-urlencoded\",\n    \"data=that\u0026i%27m=sending\u0026via=httpost\"\n)\n$next = [Execute.HttpRequest]::Send(\n    \"https://fakedomain.com/someotherresource\",\n    [System.Net.Http.HttpMethod]::Get,\n    $re.HttpResponseHeaders,\n    $re.CookieCollection\n)\n```  \n","funding_links":["https://github.com/sponsors/nstevens1040","https://ko-fi.com/nstevens1040","https://liberapay.com/nstevens1040","https://patreon.com/nstevens1040","https://paypal.me/nstevens312","https://ko-fi.com/M4M23DLL6"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnstevens1040%2Fexecute.httprequest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnstevens1040%2Fexecute.httprequest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnstevens1040%2Fexecute.httprequest/lists"}