locked
HTTP GET in 2.0 RRS feed

  • Question

  • User-283447648 posted

    I need to send a request to a payment switch with the following parameters in asp.net 2.0 C# and receive an xml response, any idea how

    Sample Request (XML)
    GET https://stageserv.interswitchng.com/test_paydirect/api/v1/gettransaction.xml?productid=21&transactionreference=8421941122&amount=300000 HTTP/1.1
    UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.239)
    Hash: F6FF2E22F99D93DDDA52D71811FD92B3A71FA1968A66216E0D310DAD

    Sample Response (XML)
    HTTP/1.0 200 OK
    Date: Tue, 30 Oct 2012 16:20:56 GMT
    Content-Type: application/xml; charset=utf-8
    Content-Length: 552
    <TransactionQueryResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ResponseCode>00</ResponseCode><ResponseDescription>Approved Successful</ResponseDescription><Amount>300000</Amount><CardNumber>6055</CardNumber><MerchantReference>8421941122</MerchantReference><PaymentReference>ZIB|WEB|VNA|15-10-2012|015933</PaymentReference><RetrievalReferenceNumber>000000538268</RetrievalReferenceNumber><SplitAccounts /><TransactionDate>2012-10-15T11:07:54.547</TransactionDate></TransactionQueryResponse>

    Thursday, May 23, 2013 3:41 AM

Answers

  • User-837620913 posted

    Use HttpWebRequest and HttpWebResponse, like this:

    HttpWebRequest request = WebRequest.Create("https://stageserv.interswitchng.com/test_paydirect/api/v1/gettransaction.xml?productid=21&transactionreference=8421941122&amount=300000");
    request.Headers.Add("Hash", "F6FF2E22F99D93DDDA52D71811FD92B3A71FA1968A66216E0D310DAD");
    
    HttpWebResponse response = (HttpWebResponse)webrequest.GetResponse();
    Encoding enc = System.Text.Encoding.GetEncoding(1252);
    StreamReader responseStream = new StreamReader(response.GetResponseStream(),enc);
    string responseString = responseStream.ReadToEnd();
    // do something here with responseString



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 23, 2013 5:28 AM

All replies

  • User-837620913 posted

    Use HttpWebRequest and HttpWebResponse, like this:

    HttpWebRequest request = WebRequest.Create("https://stageserv.interswitchng.com/test_paydirect/api/v1/gettransaction.xml?productid=21&transactionreference=8421941122&amount=300000");
    request.Headers.Add("Hash", "F6FF2E22F99D93DDDA52D71811FD92B3A71FA1968A66216E0D310DAD");
    
    HttpWebResponse response = (HttpWebResponse)webrequest.GetResponse();
    Encoding enc = System.Text.Encoding.GetEncoding(1252);
    StreamReader responseStream = new StreamReader(response.GetResponseStream(),enc);
    string responseString = responseStream.ReadToEnd();
    // do something here with responseString



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 23, 2013 5:28 AM
  • User-283447648 posted

    Thanks, It works 

    Thursday, May 23, 2013 8:13 AM