Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
11
Reply
how to send json format values in windows form application
Sivakumar
Sep 10 2015 1:48 AM
552
Reply
Hi,
This is my windows form application consume a web api.
Get values successfully but. i want to get a values in json format.
This is my code like this below :
public partial class Form1 : Form
{
string URI;
string email = ConfigurationSettings.AppSettings["email"].ToString();
string password = ConfigurationSettings.AppSettings["password"].ToString();
LoginData ld = new LoginData();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void submit_Click(object sender, EventArgs e)
{
URI = string.Concat(host.Text, api.Text);
GetLogin();
}
#region Methods
private async void GetLogin()
{
using (var client = new HttpClient())
{
var login = new LoginData() { Email = email, Password =password };
var response = await client.PostAsJsonAsync(URI, login);
if (response.IsSuccessStatusCode)
{
var productJsonString = await response.Content.ReadAsStringAsync();
body.Text = productJsonString;
}
}
}
}
#endregion
public class LoginData
{
public string Email { get; set; }
public string Password { get; set; }
}
}
How to get a values in json format
Please give me a code for that.
Thank you.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
11
)
Next Recommended Forum
Its about sunday Trainning.
Adding value to datatable and bind to gridview