TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sivakumar
NA
551
219.8k
how to use json formatters on http client
Sep 10 2015 6:41 AM
Hi ,
This is my Code :
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);//textBox2.Text + textBox1.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);
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
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; }
}
}
I want to use json formatters for return a values
Please give me a code for that
Thank you
Reply
Answers (
1
)
Need to know about the thread
how to save browser history in c#