title: Bitly URL Shortner Code example for beginner
body: <p>I'm trying to write a bitly shortener in vb.net</p>
  <p>What I did:</p>
  <p>-created the account in bitly</p>
  <p>-created the token</p>
  <p>I searched for code and want to use those snippets:</p>
  <pre><code>    'String for token
      Dim tokenString As String = &quot;xxxxxxxxxmytokenxxxxxxxx&quot;
      'Stream for the responce
      Dim responseStream As System.IO.Stream
      'Stream reader to read the stream to a string
      Dim stringStreamReader As System.IO.StreamReader
      'String to be read to
      Dim responseString As String
      'The webrequest that is querying
      Dim webRequest As WebRequest = WebRequest.Create(&quot;https://api-ssl.bitly.com/v4/shorten&quot;)
      'The collection of headers
      Dim webHeaderCollection As WebHeaderCollection = webRequest.Headers
      'Adding a header
      webHeaderCollection.Add(&quot;xxxMyUsernamexxx:Bearer &quot; + tokenString)
      'The web responce
      Dim webResponce As HttpWebResponse = CType(webRequest.GetResponse(), HttpWebResponse)
      'Reading the web responce to a stream
      responseStream = webResponce.GetResponseStream()
      'Initializing the stream reader with our stream
      stringStreamReader = New StreamReader(responseStream)
      'Reading the stream to our string
      responseString = stringStreamReader.ReadToEnd.ToString
      'Ending the web responce
      webResponce.Close()
  </code></pre>
  <p>But I get this error:</p>
  <p><img src="https://i.stack.imgur.com/7OS1x.png" alt="Image Error" /></p>
  <p>Has someone a code snippet for me which works already?</p>