User-362386836 posted
We are currently having a view in the Oracle DB which has almost 16 columns in it. We need to create a Web API that accepts the input parameters and queries the view in the Oracle DB and returns the response in the JSON format. I am new to ASP.NET and the
web services. Below is the code for the service
namespace WebApplication4.Controllers
{
public class TGSDataController : ApiController
{
public HttpResponseMessage Getdetails([FromUri] string jrs_no)
{
List<OracleParameter> prms = new List<OracleParameter>();
List<string> selectionStrings = new List<string>();
string connStr = ConfigurationManager.ConnectionStrings["TGSDataConnection"].ConnectionString;
using (OracleConnection dbconn = new OracleConnection(connStr))
{
DataSet userDataset = new DataSet();
var strQuery = "SELECT * from LIMS_SAMPLE_RESULTS_VW where JRS_NO =" + jrs_no;
var returnObject = new { data = new OracleDataTableJsonResponses(connStr, strQuery, prms.ToArray()) };
var response = Request.CreateResponse(HttpStatusCode.OK, returnObject, MediaTypeHeaderValue.Parse("application/json"));
ContentDispositionHeaderValue contentDisposition = null;
if (ContentDispositionHeaderValue.TryParse("inline; filename=TGSData.json", out contentDisposition))
{
response.Content.Headers.ContentDisposition = contentDisposition;
}
return response;
}
}
}
}
I am trying to debug and in the URL I gave like http://localhost:6897/api/TGSData?jrs_no=379
but it throws error like

I am not sure why I am getting the error. I have changed anything or not renamed.Can anyone please help me with this