public async Task <string> SendRequestWithNoBodyContentAsync(AuthenticationApiModel authentication, string methodNameAndParameters) { hp.DefaultRequestHeaders.Clear(); hp.DefaultRequestHeaders.TryAddWithoutValidation(ApiConstants.AUTHENTICATION_HEADER, authentication.UserEmail + ";" + authentication.Key); HttpContent hc = new StringContent(string.Empty, Encoding.Unicode, "application/json"); HttpResponseMessage httpResponseMessage = await hp.PostAsync(endpointUrl + methodNameAndParameters, hc); return(await httpResponseMessage.Content.ReadAsStringAsync()); }
public async Task <string> SendRequestAsync(AuthenticationApiModel authentication, string methodName, byte[] body) { hp.DefaultRequestHeaders.Clear(); hp.DefaultRequestHeaders.TryAddWithoutValidation(ApiConstants.AUTHENTICATION_HEADER, authentication.UserEmail + ";" + authentication.Key); HttpContent hc = new ByteArrayContent(body); HttpResponseMessage task = await hp.PostAsync(endpointUrl + methodName, hc); return(await task.Content.ReadAsStringAsync()); }
public string SendRequest(AuthenticationApiModel authentication, string methodName, byte[] content) { hp.DefaultRequestHeaders.Clear(); hp.DefaultRequestHeaders.TryAddWithoutValidation(ApiConstants.AUTHENTICATION_HEADER, authentication.UserEmail + ";" + authentication.Key); HttpContent hc = new ByteArrayContent(content); HttpResponseMessage httpResponseMessage = hp.PostAsync(endpointUrl + methodName, hc).Result; string response = httpResponseMessage.Content.ReadAsStringAsync().Result; return(response); }
public string SendRequest(AuthenticationApiModel authentication, string methodName, string jsonBodyObject) { hp.DefaultRequestHeaders.Clear(); hp.DefaultRequestHeaders.TryAddWithoutValidation(ApiConstants.AUTHENTICATION_HEADER, authentication.UserEmail + ";" + authentication.Key); HttpContent hc = new StringContent(jsonBodyObject, Encoding.Unicode, "application/json"); HttpResponseMessage httpResponseMessage = hp.PostAsync(endpointUrl + methodName, hc).Result; string response = httpResponseMessage.Content.ReadAsStringAsync().Result; return(response); }