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": {}
}