public string Validate([FromBody] DocumentValidationModel validationData) { try { var apiKey = "d1e15e6eeab44925b1cfcde84fe763e1"; var url = "https://sandbox-api.7oc.cl/v2/face-and-document"; var result = new TocHelper().ValidateFaceAndDocuemnt(apiKey, url, validationData); return(result.Result); } catch (Exception ex) { _logger.LogError(ex, "Error validating the data"); return(string.Empty); } }
public async Task <string> ValidateFaceAndDocuemnt(string apiKey, string url, DocumentValidationModel validationModel) { using (var client = new HttpClient()) { using (var request = new HttpRequestMessage(HttpMethod.Post, url)) { using (var content = new MultipartFormDataContent()) { content.Add(new StringContent(apiKey), "apiKey"); content.Add(new StringContent(validationModel.DocumentFront), "id_front"); content.Add(new StringContent(validationModel.DocumentBack), "id_back"); content.Add(new StringContent(validationModel.Selfie), "selfie"); content.Add(new StringContent(validationModel.DocumentType), "documentType"); request.Content = content; using (var response = await client.SendAsync(request, HttpCompletionOption.ResponseContentRead)) { var responseData = await response.Content.ReadAsStringAsync(); return(responseData); } } } } }