Send request get and receive data

Asked

Viewed 1,532 times

4

According to Pagseguro, I need to do a GET and then receive the data that comes in XML format Documentation.

I’m caught up in that part:

To consult a transaction notification, you must make a request to the Notification Query API, informing the code of the notification. The figure below illustrates a call to that API, which uses the HTTP protocol and the GET method (lines have been broken for easy reading).

So I did this:

string pagina = string.Format("https://ws.pagseguro.uol.com.br/v3/transactions/notifications/{0}?email={1}&token={2}",notificationCode, email, token);

Searching I got to this code to be doing a GET on the page:

System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(pagina);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";

But I don’t know how to proceed.

What I did, is right? And now how can I be getting the data from Pagseguro?

2 answers

2

In addition to the @Gypsy response, you should change the Method to "GET".

req.Method = "GET";

WebResponse response = req.GetResponse();

2

What I did is right?

Apparently, yes. Just testing to really know.

And how now I can be receiving the data from Pagseguro?

Sending the request:

WebResponse response = request.GetResponse();

See how to use the class WebRequest here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.