Change of behaviour for Rate Limiting
Closed this issue · 2 comments
Sometime over the past few months the behaviour of the Rate Limiting section of the API has changed. Our application catches an OAuthException which was what was thrown. This seems to have changed in the last API deploy and the library now throws an ApiResponseException with a ServiceUnavailable message. I've not been able to find any changes in the .net API that would cause this change. Email correspondence with support suggests that this is expected behaviour.
Current Stack Trace:
XeroApi.Exceptions.ApiResponseException: Xero API returned error http code: ServiceUnavailable
at XeroApi.Integration.IntegrationProxy.FindElements(IApiQueryDescription apiQueryDescription)
at XeroApi.Linq.ApiQueryProvider.Execute(Expression expression)
Current Response content:
oauth_problem=rate%20limit%20exceeded&oauth_problem_advice=please%20wait%20before%20retrying%20the%20xero%20api
With the API v2.15 release on Feb-20, the http response code for a rate limit was changed from 401 to 503. This is primarily to help differentiate between oauth/security problems and rate limit problems. Only a small number of API partners hit the rate limit on a regular basis.
I'm open to suggestions if there's a better way for the wrapper library to handle this scenario.
Dan..
For now we've modified our code to expect the new type of Exception. I do believe that this is now a better way (as it's no longer an authentication error) but I think at some point it may be worth having a dedicated status or exception to demonstrate that this is the error being experienced.