hmrc / vat-api

Apache License 2.0
67 stars 17 forks source link

Wrong response in case of error in Retrieve VAT liabilities endpoint #856

Closed lukaszszczygiel-sage closed 3 years ago

lukaszszczygiel-sage commented 3 years ago

Hi, I'm just checking the Retrieve VAT liabilities https://developer.service.hmrc.gov.uk/api-documentation/docs/api/service/vat-api/1.0#_retrieve-vat-liabilities_get_accordion

And I'm sending a request to sandbox like these /organisations/vat/479828182/liabilities?from=2020-01-01&to=2018-12-31"

In response I'm getting something like these: {"statusCode":400,"message":"DATE_RANGE_INVALID"}

I think the expected result should be:

{"statusCode":400, "code":"DATE_RANGE_INVALID", "message":"Invalid date range, must be 365 days or less"}

UPDATE: these apply to liabilities, payments and View VAT Return. Do we know if the same patter is on production

Best regards, Łukasz

hmrc-api-team commented 3 years ago

Hi @lukaszszczygiel-sage,

The VAT API is a legacy service which this team manages, but didn't originally build (and cannot substantially change). As such it contains some 'unusual' behaviours in places (especially when it comes to errors) which do not align to our current conventions and standards.

Typically we design our services to return something like:

{ "code": "FORMAT_FIELD_NAME", "message": "The provided FieldName is invalid" }

but in VAT this is not always the case as you have discovered. The API will, however, behave identically in production as in the test environment.

Kind regards, MTD API Team

lukaszszczygiel-sage commented 3 years ago

This is unfortunate. Thanks for the response.