private StringContent CreateJsonContent(QTRequestModel request) { var json = JsonConvert.SerializeObject(request); var content = new StringContent(json, Encoding.Default, "application/json"); return(content); }
public async Task <QTResponseModel> SendCommandAsync(string command, params string[] args) { var request = new QTRequestModel(command, args); var responseText = await SendRequest(request); return(JsonConvert.DeserializeObject <QTResponseModel>(responseText)); }
private async Task <string> SendRequest(QTRequestModel request) { using (var handler = CreateAuthorizedClientHandler()) using (var client = new HttpClient(handler)) { var content = CreateJsonContent(request); var result = await client.PostAsync(_walletAddress, content); AssertSuccessful(result); return(await result.Content.ReadAsStringAsync()); } }