Please update _validateResponse clients.dart code
Closed this issue · 3 comments
We happen to use the clients.dart code (commons.ApiRequester.request) to work with many other API's (Slack, Office 365, our own, ...) and it's very convenient but recently after switching to Dart2 we've discovered that not all of those API's send an integer error code so this line now fails in _validateResponse:
final code = error['code'] as int;
Would you be able to update the code to remove 'as int'?
Office 365 for example sends a String error code.
Thank you.
I think this sounds reasonable.
Is the error code of office 365 a String representation of an integer so it would make sense to parse it?
Can it have any other types?
I thought their codes were textual ones, i.e. ErrorNoItemFound, but after reviewing their docs I see integer codes as strings: https://docs.microsoft.com/en-us/previous-versions/office/office-365-api/how-to/http-response-status-codes
{ "error": { "code": "501", "message": "Unsupported functionality", "target": "query", "details": [ { "code": "301", "target": "$search" "message": "$search query option not supported", } ], "innererror": { "trace": [...], "context": {...} } } }
You know, my initial thinking was correct, in the specific case we're encountering we're getting a textual error code:
{"error":{"code":"ErrorGettingBrokerSubscription","message":"The subscription with Id 'XYZ' is not found."}}