tiagosvki93 Posted April 1, 2020 at 03:36 PM Report Share #617793 Posted April 1, 2020 at 03:36 PM 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 comment Share on other sites More sharing options...
António Fernandes Posted April 4, 2020 at 08:54 PM Report Share #617808 Posted April 4, 2020 at 08:54 PM // 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 comment Share on other sites More sharing options...
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