Skip to content

Instantly share code, notes, and snippets.

@prashantvc
Created February 13, 2015 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prashantvc/d6e8cab1e242b9c22d64 to your computer and use it in GitHub Desktop.
Save prashantvc/d6e8cab1e242b9c22d64 to your computer and use it in GitHub Desktop.
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