public class JsonSaleData { [DataMember] public string contact_attributes { get; set; } [DataMember] public string campaign_uuid = "9d119cce-25ea-46bc-b7bc-cba7e8323e91"; [DataMember] public string user_credentials = "OCPdNbeltviij8C1RLcf"; [DataMember] public string license_id = "1"; }
public class JsonSaleData private string PostSaleToClient(string url, JsonSaleData _SaleData) { string strResult = ""; try { ASCIIEncoding encoding = new ASCIIEncoding(); System.Net.HttpWebRequest httpWebRequest = (HttpWebRequest)System.Net.WebRequest.Create(url); httpWebRequest.Method = "POST"; httpWebRequest.ContentType = "application/json; charset=utf-8"; DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(JsonSaleData)); MemoryStream ms = new MemoryStream(); ser.WriteObject(ms, _SaleData); ms.Position = 0; String json = Encoding.UTF8.GetString(ms.ToArray()); StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()); streamWriter.Write(json); streamWriter.Flush(); streamWriter.Close(); System.Net.HttpWebResponse httpWebResp = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpWebResp.GetResponseStream())) { strResult = streamReader.ReadToEnd(); } return strResult; } catch (Exception ex) { string e = ex.Message; } return strResult; } /pre>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)