In this today's tutorial, I will show you how to call rest API in ASP.NET. As the Internet industry progresses, creating a REST API becomes more concrete with emerging best practices.As RESTful web services don't follow a prescribed standard except for HTTP, it's important to build your RESTful API in accordance with industry best practices to ease development and increase client adoption. A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.

RESTful APIs explicitly take advantage of HTTP methodologies defined by the RFC 2616 protocol. They simply use "PUT" to change the state of or update a resource, which can be an object, file or block; "GET" to retrieve a resource; POST" to create that resource; and "DELETE" to remove it.
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Net; 
using System.IO; 
using System.Data; 
using System.Data.Common; 
using Golive_Web.Controller; 
namespace Golive.Controller 

public class APITEXT 

Database database = new Database("GoliveAPI"); 
public DataTable GetAPI() 

DbCommand cmd = database.GetStoredPocCommand("SP_TExt"); 
DataTable dtApi = database.ExecuteDataTable(cmd); 
return dtApi; 

public string GetData(String mobileNo, String ID, String APILink) 

try 

    string XML = "<AccDtls>" + "<Request>" + "<RequestUUID>Req_" + ID + "</RequestUUID>" + "<ServiceRequestId>AcctInq</ServiceRequestId>" + "<ServiceRequestVersion>10.2</ServiceRequestVersion>" + "<ChannelId>CTS</ChannelId>" + "<AccID>" + mobileNo + "</AccID> " + "</Request>" + "</AccDtls>"; 
    const string url = "http://100.98.2.208:6070/rbl/CTSFin"; 
    HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url); 
    request.ContentType = "application/xml"; //set the content type to JSON 
    request.Method = "POST"; //make an HTTP POST 
    # 
    region test# endregion 
    using(var streamWriter = new StreamWriter(request.GetRequestStream())) 
        { 
            var resToWrite = XML; 
            streamWriter.Write(resToWrite); 
            streamWriter.Flush(); 
            streamWriter.Close(); 
        } 
        // Get the response. 
    WebResponse response = request.GetResponse(); 
    var streamReader = new StreamReader(response.GetResponseStream()); 
    string result = streamReader.ReadToEnd(); 
    return result; 

catch (Exception) 

    throw; 



}

HostForLIFE.eu ASP.NET Core 1.0 Hosting

European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.