MISSING_ARG_ACCESS_TOKEN error - bitly shorten

938 views
Skip to first unread message

Tom Weiss

unread,
Mar 16, 2014, 9:32:01 PM3/16/14
to bitl...@googlegroups.com
I'm writing a .NET 4.0 app and I need to dynamically create shortened bitly links.  I created a bitly OAuth Application and I have my access token.

When I enter something like this in a browser I get the bitly link back as expected:
https://api-ssl.bitly.com/v3/shorten?access_token=< my access token here >&format=txt&longUrl=http%3A%2F%2Fgoogle.com%2F
(of course, I replace "< my access token here >" with my actual access token)

In my .NET app I pass the exact same URL to some code (see below) to get the response to the HTTP Request.  This is vanilla code I've used before in many different situations.   Now I'm getting a "MISSING_ARG_ACCESS_TOKEN" error back from bitly in the response, even though I'm clearly passing the access token in the URL.

Any ideas why I'm getting this error?  I'd greatly appreciate any help.  The only thing I can think of is that when it works in the browser, the browser is doing something else behind the scenes when making the request that my code is not doing.


                Dim uri As New Uri(URL)

                If (uri.Scheme = uri.UriSchemeHttp) Or (uri.Scheme = uri.UriSchemeHttps) Then
                    Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
                    request.Method = WebRequestMethods.Http.Post
                    Dim response As HttpWebResponse = request.GetResponse()
                    Dim reader As New IO.StreamReader(response.GetResponseStream())
                    Dim tmp As String = reader.ReadToEnd()
                    response.Close()
                    Return tmp
                End If

Jehiah Czebotar

unread,
Mar 16, 2014, 9:43:25 PM3/16/14
to bitl...@googlegroups.com
It looks like your code snippet is making the request as a POST, you will want to make a GET request.

--
Jehiah
Head of Engineering, bitly


--
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+...@googlegroups.com.
To post to this group, send email to bitl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tom Weiss

unread,
Mar 17, 2014, 2:31:12 PM3/17/14
to bitl...@googlegroups.com
That was the problem.  Thank you so much for your quick reply!!
Reply all
Reply to author
Forward
0 new messages