Getting SSL only Error

222 views
Skip to first unread message

Gökhan Görlen

unread,
Jan 26, 2017, 3:21:07 PM1/26/17
to Bitly API
Hello

 I am using the ssl endpoint('https://api-ssl.bitly.com/v3/shorten') and access_token which i got by generating from my bitly account.But getting response as 500, 'SSLONLY'.  Please can you help me?

By the way im using webrequest here is my code : 

            XmlDocument xmlDoc = new XmlDocument();                 

            WebRequest request = WebRequest.Create("http://api-ssl.bitly.com/v3/shorten");

            byte[] data = Encoding.UTF8.GetBytes(string.Format("access_token={0}&longUrl={1}&format={2}",
             token,                             
             HttpUtility.UrlEncode(urlToShorten),         
             "xml"));                                    

            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;

            using (Stream ds = request.GetRequestStream())
            {
                ds.Write(data, 0, data.Length);
            }

            using (WebResponse response = request.GetResponse())
            {
                using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                {
                    xmlDoc.LoadXml(sr.ReadToEnd());
                }
            }

            statusCode = xmlDoc.GetElementsByTagName("status_code")[0].InnerText;
            statusText = xmlDoc.GetElementsByTagName("status_txt")[0].InnerText;
            shortUrl = xmlDoc.GetElementsByTagName("url")[0].InnerText;
            longUrl = xmlDoc.GetElementsByTagName("long_url")[0].InnerText;

Jehiah Czebotar

unread,
Jan 26, 2017, 3:31:27 PM1/26/17
to bitl...@googlegroups.com
In the code snippet you provided you just have a typo and are missing the `s` in `https`.

--
Jehiah


--
You are subscribed to the Bitly API discussion group.
for API Documentation visit http://dev.bitly.com/
---
You received this message because you are subscribed to the Google Groups "Bitly API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitly-api+unsubscribe@googlegroups.com.
To post to this group, send email to bitl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages