2

I am trying to shorten my link with the following using post man:

http://api.bitly.com/v3/shorten?callback=?login=xxxxxx&apiKey=xxxxxx4a58968824c71e281208&longUrl=http%3A%2F%2Fbetaworks.com%2F&format=json

When I run the above I get the following:

{
"status_code": 500,
"status_txt": "MISSING_ARG_LOGIN",
"data": []
}

But based on what I see here:

Using Only Javascript To Shrink URLs Using The Bit.ly API

I do not think anything is missing. Any idea?

Andy Piper
  • 11,422
  • 2
  • 26
  • 49
Hamed Minaee
  • 2,480
  • 4
  • 35
  • 63

3 Answers3

1

Replace the last question mark with ampersand:

http://api.bitly.com/v3/shorten?callback=&login=xxxxxx&apiKey=...

I had the same problem with c# (httpclient). Response code was 200 but response content contains missing_arg_login

In my case, bitly api needs a trailing slash for baseadress

Fails

BaseAddress = new Uri("https://api-ssl.bitly.com/v4")

Works

BaseAddress = new Uri("https://api-ssl.bitly.com/v4/")
Juan R
  • 193
  • 2
  • 8
1

With API V4 the schema has changed. You must send your generic token as a bearer in the header. EG Authorization: Bearer token

This endpoint has also changed to a post. Essentially it will look like this

https://api-ssl.bitly.com/v4 Headers Authorization: Bearer xyz Body: {long_url = "xyz"}

Their documentation is a little lacking. No where could I find how you were supposed to send the generic token.

Adrian
  • 3,332
  • 5
  • 34
  • 52
  • Feel free to check out this link on how to use Bitly V4, It explains where and how to send the generic token. https://stackoverflow.com/questions/59431374/bitly-api-how-to-generate-oauth2-token-to-integrate-with-bitly-api-v4-and-make/59431375#59431375 – Andrew Reese Dec 30 '19 at 16:48
0

I had this same error and by simply opening a tab in POSTMAN and creating a new request with the Header information fixed it.

If anyone ever has any trouble generating an OAuth token in version 4 of Bitly please refer to this step-by-step guide I posted.

Andrew Reese
  • 854
  • 1
  • 11
  • 27