Inconssit "data" field type in response.

224 views
Skip to first unread message

Roy Liao

unread,
Jan 18, 2018, 12:00:24 PM1/18/18
to Bitly API
All the API return the "data" field with object type. However, if there is an error, the "data" field type return as an array.
This is difficult especially you are using some gson adapter libraries. For example I am developing Android ann and I am using Retrofit with GsonConverterFactory.
In this case if I pass the wrong access token I get

{
  "status_code": 500,
  "status_txt": "INVALID_ARG_ACCESS_TOKEN",
  "data": [   
  ]
}
data is array type.

{
  "status_code": 200,
  "status_txt": "OK",
  "data": {
    "expand": [
      {
        "short_url": "https://myapp.com/2BZWJZY",
        "long_url": "https://originalurl",
        "user_hash": "2BZWJZY",
        "global_hash": "2BYGOLm"
      }
    ]
  }
}
data is different type.

Would be good if it can return as any of below:
{
  "status_code": 500,
  "status_txt": "INVALID_ARG_ACCESS_TOKEN",
  "data": null
}
{
  "status_code": 500,
  "status_txt": "INVALID_ARG_ACCESS_TOKEN"
}
{
  "status_code": 500,
  "status_txt": "INVALID_ARG_ACCESS_TOKEN",
  "data": {}
}

Peter Herndon

unread,
Jan 18, 2018, 1:39:12 PM1/18/18
to Bitly API
Hi Roy,

That's a good suggestion, I'll see if we can schedule the change.

Regards,

---Peter

Peter Herndon
@Bitly
Reply all
Reply to author
Forward
0 new messages