Post office API request

3

I have a problem with my C # code, I am trying to consume the api of the mails but the data comes null, I found another tutorial on the internet that said to instantiate the class trace and get the property rastroJSON but my service does not have this property (traceJSON), this trace property is displayed on page 7 of the post office documentation. My attempt to get the data null:

            correios.rastro a = new correios.rastro();
            correios.sroxml xml = new correios.sroxml();
            xml = a.buscaEventos("ECT", "SRO", "", "U", "", "CODIGO");
            Console.WriteLine(xml.objeto);
            Console.ReadKey();

Mail is the namespace of my reference.

the consolewriteline object comes null, I have created a service reference with the address: link

I tried to follow the manual: link , but it did not work.

I created it first with a service reference, then I tried creating a web service reference in the advanced properties.

    
asked by anonymous 04.11.2017 / 00:47

1 answer

1

Your code is correct.

    correios.rastro a = new correios.rastro();
    correios.sroxml xml = new correios.sroxml();
    xml = a.buscaEventos("usuario", "senha", "tipo", "resultado", "lingua", "objetos");
    Console.WriteLine(xml.objeto);
    Console.ReadKey();

For the Browser you have these parameters:

user

Informed by area of the Post Office in activation of the service. This one field difference letters upper and lowercase (case-sensitive).

password

Informed by area of the Post Office in activation of the service. This one field difference letters upper and lower case

type

L: list of objects. O server will make the query individual of each informed identifier; F: range of objects. O server will make the query from the first to the last reported object,

result

T: All will be returned the events of the object; U: will be returned only object's last event.

lingua

101: Will be returned all events in the Portuguese language 102: Will be returned all events in the English language.

Objects

Object code formed by 2 letters, 9 numbers and 2 letters. This field difference capital letters and lowercase (casesensitive). Example: AA458226057BR (always inform everything in capital letters).

Example: link

    
04.11.2017 / 01:06