Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to call API (use store procedure to update database) from a asp page

What I have tried:

In index.asp page when click a button, the post will call
void post (string api, string json, string token)
        {
            DefaultController DC = new DefaultController();
            DC.Insertdb(json);

            string url = api + "/Default/Insertdb?json=" + json;

            //string postData = "json=" + json;
            //ASCIIEncoding encoding = new ASCIIEncoding();
            //byte[] byte1 = encoding.GetBytes(postData);

            System.Net.WebRequest req = WebRequest.Create(url);
            req.Method = "POST";
            req.Timeout = 30000;
            req.ContentType = "application/json;charset=UTF-8";
            req.ContentLength = 0;

            WebResponse response = req.GetResponse();

Here is Insertdb:
public dynamic Insertdb(string json)
        {
            Results _result = new Results();

            var jsonData = JsonConvert.DeserializeXmlNode(json);
            dynamic jsonData1 = JsonConvert.DeserializeXmlNode(json);
            string xmlData = jsonData.OuterXml;
            xmlData = "<NewDataSet>" + xmlData + "</NewDataSet>";

            DBHelp db = new DBHelp();

            db.AddParameter("@_DataConvert", xmlData);

            try
            {
                SqlDataReader reader = db.ExecuteReader("usp_SyncData_Bravo_CRM_Add", CommandType.StoredProcedure);

When i trace by fiddler, it not have JSON result
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900