Cis Pa

Cis Pa

  • NA
  • 194
  • 22.9k

Return DataSet in REST Web Api and return as dataset in Clientapp

Jun 8 2021 3:07 AM

Hi all,

I was trying to return a result as Dataset in REST Web Api and consume in client application as Dataset .

Is it possible to return result as Dataset into Rest web api  and am getting error "Additional text found in JSON string after finishing deserializing object." plz help.

public Dataset Getstudent(string schoolId)
{
    try
    {
        SqlDataAdapter da = new SqlDataAdapter("Getstudent", con);
        DataTable ds = new DataTable();
        con.Open();
        da.SelectCommand.CommandType = CommandType.StoredProcedure;
        SqlParameter ret = new SqlParameter();
        ret.Direction = ParameterDirection.ReturnValue;
        da.SelectCommand.Parameters.Add("@schoolId", SqlDbType.VarChar, 20).Value = schoolId;
        da.SelectCommand.Parameters.Add(ret);
        da.Fill(ds);
        return Ok(ds);    
    }
}
private async  Task StoredDataset()
{
    DataSet ds = new DataSet();

    var resultapi =  client.GetAsync(builder.Uri).Result;
    if (resultapi.IsSuccessStatusCode)
    {
        var jsonString = await resultapi.Content.ReadAsStringAsync();
        ds = JsonConvert.DeserializeObject(jsonString);
    }
}

 


Answers (1)