コード例 #1
0
ファイル: DataMotion.cs プロジェクト: DataMotionInc/DMWeb
 public SMTPCredentialsModel PutSMTPEndpoints(string sessionKey, SMTPEndpoint2Model[] smtpEndpoints)
 {
     //Send Payload
     var req = new WebClient();
     req.BaseAddress = endpoint + "/Remote/Smtp/PutSmtpEndpoints";
     req.Headers.Clear();
     req.Headers.Add("Accept", "application/json");
     req.Headers.Add(Headers.SessionKey, sessionKey);
     try
     {
         var request = req.UploadData(endpoint + "/Remote/Smtp/PutSmtpEndpoints", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(smtpEndpoints)));
         return JsonConvert.DeserializeObject<SMTPCredentialsModel>(Encoding.UTF8.GetString(request));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
コード例 #2
0
ファイル: DataMotion.cs プロジェクト: DataMotionInc/DMWeb
 public SMTPCredentialsModel PutSMTPEndpoints(string sessionKey, SMTPEndpoint2Model[] smtpEndpoints)
 {
     //Send Payload
     var req = new HttpClient();
     req.BaseAddress = new Uri(endpoint + "/Remote/Smtp/PutSmtpEndpoints");
     req.DefaultRequestHeaders.Accept.Clear();
     req.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
     req.DefaultRequestHeaders.Add(Headers.SessionKey, sessionKey);
     var request = req.PutAsJsonAsync(endpoint + "/Remote/Smtp/PutSmtpEndpoints", smtpEndpoints);
     if (request.Result.IsSuccessStatusCode)
     {
         var data = request.Result.Content.ReadAsStringAsync().Result;
         DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(SMTPCredentialsModel));
         return (SMTPCredentialsModel)serializer.ReadObject(request.Result.Content.ReadAsStreamAsync().Result);
     }
     else
     {
         throw new Exception(request.Result.Content.ReadAsStringAsync().Result);
     }
 }