Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Pass Querystring in C# httpclient

using System.Net.Http;

var builder = new UriBuilder
{
    Scheme = Uri.UriSchemeHttps,
    Port = -1,
    Host = "https://example.com",
    Path = "api"
};

var query = builder.Uri.ParseQueryString();
query["name"] = "aaa";
query["key"] = "123-456";

builder.Query = query.ToString();
var stringUri = builder.ToString();
// https://example.com/api?name=aaa&key=123-456

HttpClient client = new HttpClient();
var response = await client.GetAsync(stringUri);
 
PREVIOUS NEXT
Tagged: #Pass #Querystring #httpclient
ADD COMMENT
Topic
Name
7+2 =