Search
 
SCRIPT & CODE EXAMPLE
 

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);
Comment

PREVIOUS NEXT
Code Example
Csharp :: Convert array of strings to List<string 
Csharp :: update multiple records with entity framework 
Csharp :: c# write to output window 
Csharp :: array sorting c# 
Csharp :: roman 
Csharp :: join two array c# 
Csharp :: check if file exist c# 
Csharp :: C# program that joins List of strings 
Csharp :: c# read last 10 lines of file 
Csharp :: datatable to array c# 
Csharp :: c# execute shell command 
Csharp :: sorting a list of objects in c# 
Csharp :: unity check gameobject active 
Csharp :: how to set picturebox width with form width in c# 
Csharp :: how to make button in asp.net to go to other page 
Csharp :: C# Http.HttpRequestMessage 
Csharp :: find how many digits a number has csharp 
Csharp :: make command prompt hidden c# 
Csharp :: .net core web app get dll name 
Csharp :: c# char 
Csharp :: c# remove item from list 
Csharp :: how do you make a 2D object follow another 2D object in unity 2D 
Csharp :: random in f# 
Csharp :: c# streamwriter add new line 
Csharp :: C# select keyword lambda 
Csharp :: windows forms get all images from resources 
Csharp :: custom click event wpf button 
Csharp :: parse strings into words C# 
Csharp :: Map Range Clamped unity 
Csharp :: unity draw ray from one object to another 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =