ASP.NET MVC integration

FadyY8
Frequent Participant

ASP.NET MVC integration

Hello,

I have spent a total of 30 hours so far trying to integrate your API endpoints with MVC project that my company has.

Do you have any C# examples I can look at?

This is my snippet but I am getting an error (grant_type is required).

 

 

            if (Request.QueryString["access_token"] != null)

            {

                code = Request.QueryString["access_token"];           

                ResponseAPI response = new ResponseAPI();

                try

                {

                    using (var webClient = new WebClient())

                    {

                        byte[] bytes = Encoding.GetEncoding("ISO-8859-1").GetBytes(apiKey + ":" + client_secret);

                        string encodedData = Convert.ToBase64String(bytes);

                        string _params = "redirect_uri=https://localhost&grant_type=authorization_code&code=" + code;

                        var url = "https://idfed.constantcontact.com/as/token.oauth2";

 

                        webClient.Headers.Add("Accept", "application/json");

                        webClient.Headers.Add("Authorization", "Basic " + encodedData);

                        

                        response.Response = webClient.UploadString(url, "POST", _params);

                    }

                }

                catch (WebException we)

                {

                    using (var sr = new StreamReader(we.Response.GetResponseStream()))

                    {

                        response.Response = sr.ReadToEnd();

                    }

                }           

}

0 REPLIES 0
Developer Portal

View API documentation, code samples, get your API key.

Visit Page