I am new to Apex and SF and I have to manage some errors from an 3rd party API we are calling. I have been using DTO with very simple response objects and the error response object we get back has one more level.
JSON response from API:
{
"error": {
"message": "File couldn't be downloaded: main_panel"
}
}
DTO file:
public class CreateCadRequestError {
public string error;
public CreateCadRequestErrorMessage message;
}
public class CreateCadRequestErrorMessage {
public string message;
}
Apex class deserializing data
class SoloConnector {
resp = makeNetworkCall()...
SoloDTO.CreateCadRequestError resp = ( SoloDTO.CreateCadRequestError )JSON.deserialize( response.getBody(), SoloDTO.CreateCadRequestError.class );
System.debug('resp: ' + resp.error + resp.message);
}
I am getting an error
illegal value for primitive
I assume its my DTO class and not being able to serialize the data. Any suggetsions?