Beispiel #1
0
 public AccountListModel List(string sessionKey, AccountIndexRequestModel accountIndexRequest)
 {
     //Send Payload
     var req = new WebClient();
     req.BaseAddress = endpoint + "/Remote/Account/List";
     req.Headers.Clear();
     req.Headers.Add("Accept", "application/json");
     req.Headers.Add(Headers.SessionKey, sessionKey);
     try
     {
         var request = req.UploadData(endpoint + "/Remote/Account/List", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(accountIndexRequest)));
         return JsonConvert.DeserializeObject<AccountListModel>(Encoding.UTF8.GetString(request));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Beispiel #2
0
 public AccountListModel List(string sessionKey, AccountIndexRequestModel accountIndexRequest)
 {
     //Send Payload
     var req = new HttpClient();
     req.BaseAddress = new Uri(endpoint + "/Remote/Account/List");
     req.DefaultRequestHeaders.Accept.Clear();
     req.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
     req.DefaultRequestHeaders.Add(Headers.SessionKey, sessionKey);
     var request = req.PostAsJsonAsync(endpoint + "/Remote/Account/List", accountIndexRequest);
     if (request.Result.IsSuccessStatusCode)
     {
         var data = request.Result.Content.ReadAsStringAsync().Result;
         DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AccountListModel));
         return (AccountListModel)serializer.ReadObject(request.Result.Content.ReadAsStreamAsync().Result);
     }
     else
     {
         throw new Exception(request.Result.Content.ReadAsStringAsync().Result);
     }
 }