HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://example.com/api"); request.Headers.Add("Authorization", "Bearer myAccessToken");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://example.com/api"); request.Headers.Add("Authorization", "Bearer myAccessToken"); request.Headers.Add("X-Custom-Header", "customValue");In this example, two custom headers are being added to an HttpWebRequest object - Authorization and X-Custom-Header. This might be useful for passing additional metadata to a web API. The HttpRequest AddHeader method is part of the System.Net namespace in C#. To use this method, you will need to include the System.Net namespace in your project.