Working with AmenDataSync
This commit is contained in:
parent
360a71f986
commit
b8b499630a
@ -10,6 +10,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net;
|
||||
|
||||
namespace Amen.Controllers
|
||||
{
|
||||
@ -645,7 +646,6 @@ namespace Amen.Controllers
|
||||
ApplicationDbContext db = new ApplicationDbContext();
|
||||
Affiliate affiliate = db.Affiliates.Find(affiliateId);
|
||||
|
||||
//string APIUrl = "http://localhost:7157/api/AmenDataSync";
|
||||
string APIUrl = "https://amendatasync.azurewebsites.net/api/AmenDataSync";
|
||||
APIUrl += "?task=" + task +
|
||||
"&brand=" + affiliate.Name +
|
||||
@ -654,29 +654,22 @@ namespace Amen.Controllers
|
||||
"&email=" + email +
|
||||
"&phone=" + phone;
|
||||
|
||||
try
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.BaseAddress = new Uri(APIUrl);
|
||||
client.DefaultRequestHeaders.Accept.Clear();
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
HttpResponseMessage response = await client.GetAsync(APIUrl);
|
||||
//var result = client.GetAsync(APIUrl).Result;
|
||||
client.BaseAddress = new Uri(APIUrl);
|
||||
client.DefaultRequestHeaders.Accept.Clear();
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
HttpResponseMessage response = await client.GetAsync(APIUrl);
|
||||
//var result = client.GetAsync(APIUrl).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var readTask = response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
var rawResponse = readTask.GetAwaiter().GetResult();
|
||||
}
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var readTask = response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
var rawResponse = readTask.GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user