tiagosvki93 0 Posted April 1, 2020 Report Share Posted April 1, 2020 Boa tarde a toda a comunidade. Estou a tentar implementar no meu projecto em Winforms C#, a consulta à plataforma nif.pt utilizado o webservice disponibilizado por eles. Já tentei vários procedimentos para "ler" o retorno, mas ainda não consegui nenhum resultado. Alguém já fez este procedimento, que me possa dar umas dicas? Obrigado desde já, Cumprimentos, Tiago Marques Link to post Share on other sites
António Fernandes 0 Posted April 4, 2020 Report Share Posted April 4, 2020 // API-KEY cfeb4a166 ....... c7d8a3a3940aac string nif = txtNIF.Text.Trim(); string link = "http://www.nif.pt/?json=1&q=" + nif + "&key=cfeb4a166 ....... c7d8a3a3940aac"; try { using (var client = new WebClient()) { var json = client.DownloadString(link); JObject jsonObj = JObject.Parse(json); JObject nifObj = (JObject)jsonObj["records"][nif]; // teste ok MessageBox.Show(nifObj["address"].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.Message); } Este é um exemplo básico e sem preocupações com boas práticas. Espero que ajude. Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now