public Correios.consultaCEPResponse GetByCep(string cep) { Correios.AtendeClienteClient correiosApi = new Correios.AtendeClienteClient(); Correios.consultaCEPResponse consulta = correiosApi.consultaCEPAsync(cep).Result; return(consulta); }
public ActionResult GetByCep(string cep) { DeliveryAddressApi api = new DeliveryAddressApi(); try { Correios.consultaCEPResponse consulta = api.GetByCep(cep); if (consulta != null) { return(Ok(Json(consulta.@return))); } else { return(BadRequest("Faild to request address.")); } } catch (Exception ex) { return(BadRequest(ex.Message)); } }