Skip to content

Instantly share code, notes, and snippets.

@feeeper
Created August 25, 2016 12:03
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 feeeper/d94c6576bfba766590b5c4e97b86af65 to your computer and use it in GitHub Desktop.
Save feeeper/d94c6576bfba766590b5c4e97b86af65 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
public static void Main(string[] args)
{
DoWork();
}
static async void DoWork()
{
string proxyUri = string.Format("{0}:{1}", "proxy.address.com", 3128);
NetworkCredential proxyCreds = new NetworkCredential(
"username@domain",
"password"
);
WebProxy proxy = new WebProxy(proxyUri, false)
{
UseDefaultCredentials = false,
Credentials = proxyCreds,
};
HttpClientHandler handler = new HttpClientHandler()
{
Proxy = proxy,
PreAuthenticate = true,
UseDefaultCredentials = true,
};
using (var client = new HttpClient(handler))
{
try
{
const string baseUri = "https://energydevdealswebservices20160719041846.azurewebsites.net/";
client.BaseAddress = new Uri(baseUri);
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("deadId", "3"),
new KeyValuePair<string, string>("flagValueToSet", "true")
});
// var response = client.PostAsync("https://energydevdealswebservices20160719041846.azurewebsites.net/Deals/SetDealFlag?dealId=3&flagValueToSet=true", content); // response.Result.IsSuccessStatusCode == true
var response = client.PostAsync("https://energydevdealswebservices20160719041846.azurewebsites.net/Deals/SetDealFlag", content); // response.Result.IsSuccessStatusCode == false
response.Wait();
if (response.Result.IsSuccessStatusCode)
{
return;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment