У нас работает отправка POST запроса из процесса
Только если https то мы указывали еще и порт https://url:443
Код:
[Serializable]
public class SaleJsonPost
{
[JsonProperty (PropertyName = "command")]
public string Command {
get;
set;
}
[JsonProperty (PropertyName = "id_source")]
public string Source {
get;
set;
}
[JsonProperty (PropertyName = "id_crm")]
public string CRM {
get;
set;
}
[JsonProperty (PropertyName = "roistat_visit")]
public string Visit {
get;
set;
}
[JsonProperty (PropertyName = "data")]
public Data Array {
get;
set;
}
}
[Serializable]
public class Data
{
[JsonProperty (PropertyName = "name")]
public string Name {
get;
set;
}
[JsonProperty (PropertyName = "fio")]
public string FullName {
get;
set;
}
[JsonProperty (PropertyName = "phone")]
public string Phone {
get;
set;
}
}
public class Response
{
[JsonProperty (PropertyName = "code")]
public string Code {
get;
set;
}
[JsonProperty (PropertyName = "description")]
public string Descr {
get;
set;
}
[JsonProperty (PropertyName = "id")]
public string Id {
get;
set;
}
}
// отправка запроса и получение ответа
SaleJsonPost salePost = new SaleJsonPost ();
salePost.Command = "save_lead";
salePost.CRM = "3";
salePost.Source = "5";
salePost.Visit = "неизвестно";
salePost.Array = new Data () {
Name = context.NaimenovanieLida,
FullName = context.FamiliyaKlienta + " " + context.ImyaKlienta,
Phone = context.TelefonKlienta.PhoneString
};
string json = JsonConvert.SerializeObject (salePost);
var httpRequest = (HttpWebRequest)WebRequest.Create ("URL");
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
using (var requestStream = httpRequest.GetRequestStream ())
using (var writer = new StreamWriter (requestStream)) {
writer.Write (json);
}
using (var httpResponse = httpRequest.GetResponse ())
using (var responseStream = httpResponse.GetResponseStream ())
using (var reader = new StreamReader (responseStream)) {
string response = reader.ReadToEnd ();
var responseDes = JsonConvert.DeserializeObject<Response> (response);
lead.Description = "Промокод: неизвестно" + responseDes.Id;
context.ID_BD = Convert.ToInt32 (responseDes.Id);
}