Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Http;

namespace WebApplicationfortestingapi
{
    public partial class WebForm1txtbutton : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            HttpClient client = new HttpClient(); //for request and response
            string gstId = txtgstNumber.Text;
             string path = API=" + gstId;
            HttpResponseMessage response = client.GetAsync(path).Result; 
            
            if (response.IsSuccessStatusCode)
            {
                var jsonString = response.Content.ReadAsStringAsync(); 
                string result = jsonString.Result;
                if (result == "True")
                {
                    lblmsg.Text = "Valid GST Number";
                }
                else {
                    lblmsg.Text = "Invalid GST Number";
                }
            }
            else {
                lblmsg.Text = "API Not Hitting";
            }
        }
    }


What I have tried:

Please give the gst number validationAPI
Thanks in Advance
Posted
Updated 28-Feb-23 3:21am
v3
Comments
Chris Copeland 28-Feb-23 8:15am    
Aside from the immediate code issues, what exactly is the problem you're having? I doubt this exact code would even run, but you've not properly explained what the issue is. Are you calling an API and getting an invalid response? What is the value of the API variable you're trying to use in the the path variable? Is the code throwing an exception, if it is then what does the exception tell you?

1 solution

To do that, you will need to access the Indian tax man, or pay for the privelige.
Start here: validate gst number - Google Search[^]
 
Share this answer
 

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