Table of Contents

Getting Started with HttpBuildR Request

HttpBuildR Request is a fluent API for building and working with HttpRequestMessage objects. This guide will help you get started with using HttpBuildR in your projects.

Installation

To use this library, simply include HttpBuildR.Request.dll in your project or grab it from NuGet, and add this to the top of each .cs file that needs it:

using HttpBuildR;
using Req = HttpMethod;

If you're using implicit usings the above is not necessary.

Creating a Request

You can create a new HttpRequestMessage using the To method:

HttpRequestMessage request = HttpMethod.Get.To("https://example.com");

This creates a new GET request to https://example.com.

Modifying Headers

HttpBuildR provides a set of methods to modify the headers of an HttpRequestMessage. For more information, see the Request Headers guide.

Here's an example of how you can add a header to a request:

request = request.WithHeader("headerName", "headerValue");

Modifying Content

HttpBuildR also provides methods to modify the content of an HttpRequestMessage. For more information, see the Request Content guide.

Here's an example of how you can add JSON content to a request:

request = request.WithJsonContent(new { Name = "Ben", Age = "Unknown" });

Sending the Request

Once you've built your request, you can send it using an HttpClient:

HttpClient client = new HttpClient();
HttpResponseMessage response = await client.SendAsync(request);

This sends the request and returns the response.

That's it! You're now ready to start using HttpBuildR in your projects.