Ameer Ali Shar
Ameer Ali Shar

Reputation: 54

How to Call Web API in Asp.Net WebForm?

screenshot of text

I want to call this API in C#, same parameter will be passed.

It's working fine on POSTMAN; I just want to call from asp.net Web Form

Upvotes: 0

Views: 1546

Answers (1)

Jonathan Delean
Jonathan Delean

Reputation: 1084

Use that :

var values = new Dictionary<string, string>
{
    { "thing1", "hello" },
    { "thing2", "world" }
};

var content = new FormUrlEncodedContent(values);

var response = await client.PostAsync("http://www.example.com/recepticle.aspx", content);

var responseString = await response.Content.ReadAsStringAsync();

Upvotes: 1

Related Questions