Skip to content

Instantly share code, notes, and snippets.

@prashantvc prashantvc/MainClass.cs Secret
Created Feb 13, 2015

Embed
What would you like to do?
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine ("Hello World!");
MainClass m = new MainClass ();
m.CreateSession ();
Console.ReadLine ();
}
public async Task CreateSession ()
{
using (var client = new HttpClient ()) {
var url = string.Format ("https://localhost/AuthService.svc/" + "ValidateUserNW");
var json = "{\"Username\":\"jh\",\"Password\":\"kj\"}";
HttpContent content = new StringContent (json,
Encoding.UTF8,
"application/json");
try {
client.DefaultRequestHeaders.Add ("User-Agent", "Finder/1.0.0.0 (Android; Nexus 4 (KitKat) OS 4.4.2)");
} catch (Exception e) {
Console.WriteLine (e);
}
// Need by service, don't remove
var resp = await client.PostAsync (url, content);
Console.WriteLine (resp);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.