3.54Setting HttpRequestMessage Properties

Created on Aug 17, 2026~1 min read

In specific scenarios, we may need to add additional properties to the HttpRequestMessage request rather than through request headers. In that case, you can do the following:

cs
HttpRequestBuilder.Get("https://furion.net")    .WithProperty("key1", "vallue2")    // Set a single property    .WithProperties(new Dictionary<string, object?> {}) // Set multiple properties    .WithProperties(new { id = 1, name = "Furion" });   // Set multiple properties

These properties are added to the Options property of the HttpRequestMessage object (reference documentation). To retrieve these values, you can do the following:

cs
httpRequestMessage.Options.TryGetValue(new HttpRequestOptionsKey<string>("key1"), out var value);

If a property key is duplicated, the value set later will override the previous setting.