Android Question Invalid Json string return when I use Job.GetString() Method

junaidahmed

Well-Known Member
Licensed User
Longtime User
I have an web service that returns the below json string.it return fine in ASP.net Web Service but at the same time when I get the Json String from B4ACode using (Job.Gettring() Method) it show an json string and addition html tag .Please check the below response ..

Json String in WebService:-

Json String:
[{"Message":"Hemming Out Not Done for This Cut Slip 2103467 ... Please Check !!! "}]

Jsonstring in B4A Code :-

Json String in B4A using Job.GetString() Method:
[{"Message":"Hemming Out Not Done for This Cut Slip 2103467    ... Please Check !!! "}]



<!DOCTYPE html>



<html xmlns="http://www.w3.org/1999/xhtml">

<head><title>



</title></head>

<body>

    <form method="post" action="FrmProductionEntry.aspx?Cutslip=2103467&amp;Operation=070901&amp;Code=10803&amp;Name=SARGUNA.S&amp;Style=CO168%2f01++&amp;Pairs=11&amp;OT=0&amp;Hours=8&amp;TableCode=LN01" id="form1">

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZHOeU1EPNhKBCmtmpNfbntLkvU5/QIvfNc18tifWPLsK" />



<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="2EC8893F" />

        <div>

        </div>

    </form>

</body>

</html>
 

KMatle

Expert
Licensed User
Longtime User
Upvote 0

junaidahmed

Well-Known Member
Licensed User
Longtime User
See the below aspx code

ASP.net Code that return Json String:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLToolkit.Data;
using Newtonsoft.Json;

namespace Android
{
    public partial class FrmProductionEntry : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string Operation = Request.QueryString["Operation"].ToString();
            string Code =  Request.QueryString["Code"].ToString();
            string Name = Request.QueryString["Name"].ToString();
            string CutSlip = Request.QueryString["CutSlip"].ToString();
            string Style = Request.QueryString["Style"].ToString();
            int Pairs = Convert.ToInt32(Request.QueryString["Pairs"]);
            int OT = Convert.ToInt32(Request.QueryString["OT"]);
            string Hours = Request.QueryString["Hours"].ToString();
            string TableCode = Request.QueryString["TableCode"].ToString();
                      

            using (DbManager Db = new DbManager())
            {
                string Result = "";
                Result = Db.SetSpCommand("Arind.Dbo.SpProductionEntry",
                    Db.InputOutputParameter("@Message", Result),
                    Db.InputParameter("@CutSlip", CutSlip),
                    Db.InputParameter("@Operation", Operation),
                    Db.InputParameter("[USER=93151]@code[/USER]", Code),
                    Db.InputParameter("[USER=50922]@name[/USER]", Name),
                    Db.InputParameter("@Style", Style),
                    Db.InputParameter("@Pairs", Pairs),
                    Db.InputParameter("@OverTime", OT),
                    Db.InputParameter("@Hours", Hours),
                    Db.InputParameter("[USER=115178]@table[/USER]", TableCode)).ExecuteScalar<string>(ScalarSourceType.OutputParameter);
              


                DataTable dt = new DataTable();
                DataColumn dc = new DataColumn("Message", typeof(String));
                dt.Columns.Add(dc);
                DataRow dr = dt.NewRow();
                dr[0] = Result;
                dt.Rows.Add(dr);

                Response.Write(DataTableToJSONWithJSONNet(dt));
                Db.Close();
                Db.Dispose();



                //return Result;
            }

        }

        

        public string DataTableToJSONWithJSONNet(DataTable table)
        {

            string JSONString = string.Empty;
            JSONString = JsonConvert.SerializeObject(table);
            return JSONString;

        }
    }

}
 
Upvote 0
Top