public async Task <ResponseTOCContractDTO> CreateContract(ContractInvestor contractInvestor) { NewRequestContractDTO contractToSend = GetNewContractToSign(contractInvestor); ResponseTOCContractDTO responseContractDTO = new ResponseTOCContractDTO(); using (var httpClient = new HttpClient()) { string jsonSigners = JsonConvert.SerializeObject(contractToSend.Signers); ////Convert object properties in lowercase var newContractObject = JObject.Parse(jsonSigners, new JsonLoadSettings()); JsonHelpers.ChangePropertiesToLowerCase_TOC(newContractObject); try { httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("multipart/form-data")); httpClient.DefaultRequestHeaders.Add("Authorization", _tocSettings.API_Key); using (var form = new MultipartFormDataContent()) { string filePath = @"Template_Investor\" + contractInvestor.FileName; using (var fileContent = new ByteArrayContent(await File.ReadAllBytesAsync(filePath))) { fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data"); form.Add(fileContent, "file", Path.GetFileName(filePath)); form.Add(new StringContent(newContractObject.ToString()), "signers"); form.Add(new StringContent(contractToSend.Message), "message"); form.Add(new StringContent(contractToSend.Lang), "lang"); var builder = new UriBuilder(new Uri(_tocSettings.API_Url + EndPointURL)); using (var response = await httpClient.PostAsync(builder.Uri, form)) { string apiResponse = await response.Content.ReadAsStringAsync(); responseContractDTO = JsonConvert.DeserializeObject <ResponseTOCContractDTO>(apiResponse); } } } } catch (Exception ex) { throw ex; } } return(responseContractDTO); }