Standard Response Structure (ResponseDto)

Within the Tailoor API framework, efficiently managing responses and errors is key to seamless integration and ensuring smooth communication between systems. The ResponseDto represents the standard response structure utilized by the Tailoor API to communicate the outcomes of requests, whether they are successful operations or encountered errors. Understanding this structure is crucial for accurately interpreting API responses.

Component Breakdown

  • Code (string?): This field contains a code that represents the outcome of the operation. In the event of success, it can indicate a specific code associated with the performed action. In case of failure, it provides an initial indication of the problem’s nature.
  • Reason (string?): Provides a human-readable description of the operation or error, offering additional context about the result of the API request.
  • Errors (Dictionary<string, ErrorInfoDto>?): If errors are encountered during the processing of the request, this field will contain a detailed dictionary of identified errors, allowing for precise and targeted diagnosis.
				
					/// <summary>
/// Risposta standard
/// </summary>
public class ResponseDto
{
    /// <summary>
    /// Codice del messaggio
    /// </summary>
    [JsonProperty("code")]
    public string? Code { get; set; }
        
    /// <summary>
    /// Descrizione del messaggio
    /// </summary>
    [JsonProperty("reason")] 
    public string? Reason { get; set; }
        
    /// <summary>
    /// Eventuali errori
    /// </summary>
    [JsonProperty("errors")]
    public Dictionary<string, ErrorInfoDto>? Errors { get; set; }
}
				
			

Error Detail Structure (ErrorInfoDto)

For situations where requests result in one or more errors, the ErrorInfoDto class offers specific information on each error.

  • Code (string?): A unique identifier for the specific error, which can be used for programmatic error handling.
  • Reason (string?): A description of the error that provides further details on why it occurred, aiding in the development of solutions.
				
					/// <summary>
/// Descrizione dell'errore
/// </summary>
public class ErrorInfoDto
{
    /// <summary>
    /// Codice dell'errore
    /// </summary>
    [JsonProperty("code")]
    public string? Code { get; set; }
        
    /// <summary>
    /// Description dell'errore
    /// </summary>
    [JsonProperty("reason")]
    public string? Reason { get; set; }
}
				
			

Error Response Example

{
  "code": "ValidationError",
  "reason": "Validation failed for the input fields",
  "errors": {
    "username": {
      "code": "Required",
      "reason": "The username field is required."
    },
    "email": {
      "code": "Invalid",
      "reason": "The email address is not in a valid format."
    }
  }
}

In this example, the API communicates that the input field validation failed, providing specific details on the identified errors (missing username field and invalid email format).

This structure aims to provide a clear understanding of API request outcomes, facilitating developers in quickly identifying and resolving errors. By adhering to this standardization, the Tailoor API commits to delivering an optimal integration experience.

				
					/// <summary>
/// Risposta standard
/// </summary>
public class ResponseDto
{
    /// <summary>
    /// Codice del messaggio
    /// </summary>
    [JsonProperty("code")]
    public string? Code { get; set; }
        
    /// <summary>
    /// Descrizione del messaggio
    /// </summary>
    [JsonProperty("reason")] 
    public string? Reason { get; set; }
        
    /// <summary>
    /// Eventuali errori
    /// </summary>
    [JsonProperty("errors")]
    public Dictionary<string, ErrorInfoDto>? Errors { get; set; }
}