Generate `x-www-form-urlencoded` content in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Net.Http; | |
using System.Text; | |
namespace FormUrlEncodedContentExample | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var dict = new Dictionary<string, string> | |
{ | |
{ "page", "kantlista" }, | |
{ "kod", "A0004n" }, | |
{ "termin", "H12" }, | |
{ "anmkod", "17113" }, | |
{ "urval", "ant" }, | |
{ "listVal", "namn" }, | |
{ "method", "Sök" } // S%F6k | |
}; // dict | |
var content = new FormUrlEncodedContent(dict); | |
var memStream = new MemoryStream(); | |
content.CopyToAsync(memStream).Wait(); | |
byte[] data = memStream.GetBuffer(); | |
var str = Encoding.UTF8.GetString(data); | |
Console.WriteLine(str); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment