A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories.
Hi @KALYANA ALLAM,
You can use JsonConvert.SerializeObject to serialize a query into a JSON string.
string jsonData = JsonConvert.SerializeObject(query);
Because your API has a pair of square brackets, you need to remove the square brackets to match.
var a = strJSON.Substring(1, strJSON.Length - 2);
protected void Button1_Click(object sender, EventArgs e)
{
string uid = TextBox1.Text;
string pass = TextBox2.Text;
var query = new Dictionary<string, string>()
{
["userid"] = uid,
["password"] = pass
};
string jsonData = JsonConvert.SerializeObject(query);
var uri = QueryHelpers.AddQueryString("https://sheet2api.com/v1/CAdt0QU7TXCy/credentials/", query);
var client = new HttpClient();
var response = client.GetAsync(uri).Result;
if (response.IsSuccessStatusCode)
{
var strJSON = response.Content.ReadAsStringAsync().Result;
var a = strJSON.Substring(1, strJSON.Length - 2);
if (a != jsonData)
{
Label4.Text = "Invalid Credentials.!!";
}
else
{
Session["fromlogin"] = "Y";
Response.Redirect("Main.aspx");
}
}
else
{
Label4.Text = "Invalid Credentials.!!";
}
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.