commercetools-python-sdk
commercetools-python-sdk copied to clipboard
Error response cannot be parsed
Tested version: 14.0.0b12
Problem commercetools SDK raises an Exception (no CommercetoolsError) because it cannot parse an error response from commercetools;
Could not parse error response
This is due to a validation error:
{'errors': {0: {'actionIndex': ['Unknown field.'], 'action': ['Unknown field.']}}}
In the following block:
try:
obj = ErrorResponseSchema().loads(response.content)
except ValidationError:
raise Exception(f"Could not parse error response: {response.content}")
Example response:
b'{"statusCode":400,"message":"A value is required for field \'contract\'.","errors":[{"code":"RequiredField","message":"A value is required for field \'contract\'.","action":{"action":"setCustomField","name":"someCustomField","value":"24e3565c-9135-ec11-a459-6045bd8b7265"},"actionIndex":1,"field":"contract"}]}'