Skip to content

ErrorArchive Entity Properties

Each entity in ErrorArchive has the following properties:

Name Type Description
RequestID Edm.Int64 An incrementing unique integer assigned to each request.
CustomTag Edm.String The value of the custom tag field of the offending request (if a value for the custom tag field was specified when sending the request ).
HTTPStatusCode Edm.Int32 The HTTP status code returned in the response from the OData service.
Code Edm.String The vendor error code returned in the response from the OData service.
Message Edm.String The vendor error message returned in the response from the OData service.
InnerError Edm.String The vendor inner error returned in the response from the OData service.
Domain Edm.String The domain of the error.
RequestMethod Edm.String The HTTP method of the offending request (POST, PUT, PATCH or DELETE).
RequestURL Edm.String The URL of the offending request.
RequestBody Edm.String The body (payload) of the offending request.
AffectedEntity Navigation Property A navigation property that allows an application to navigate from an ErrorArchive entity to an entity in the offline store that is affected by the error.

Code Sample

The sample below shows how to access ErrorArchive (if errors have occurred) using the dynamic API.

/// Set up entity set, entity type and properties for ErrorArchive
let errorArchiveSet: EntitySet = eventService.entitySet(withName: "ErrorArchive")
let errorArchiveType: EntityType = errorArchiveSet.entityType

/// Navigation property
let affectedEntityProp = "AffectedEntity")

/// Structural properties
let requestIDProp = "RequestID")
let requestBodyProp = "RequestBody")
let httpStatusCodeProp = "HTTPStatusCode")
let codeProp = "Code")
let messageProp = "Message")
let requestMethodProp = "RequestMethod")
let requestURLProp = "RequestURL")

let errorArchiveQuery = DataQuery().from(errorArchiveSet)

/// See if there are any errors in the ErrorArchive entity set
let nErrors = try eventService.executeQuery(errorArchiveQuery).count()

/// Get the list of errors in the ErrorArchive entity set
let errors = try eventService.executeQuery(errorArchiveQuery).entityList()

/// Examine the first error entry (giving that there is at least one error)
let error = errors.first()

/// Get request ID
let requestID = requestIDProp.longValue(from: error)

/// Get request body
let requestBody = requestBodyProp.stringValue(from: error)

/// Get Http Status Code returned
let httpStatusCoce = httpStatusCodeProp.intValue(from: error)

/// Get error code returned
let code = codeProp.stringValue(from: error)

/// Get error message
let message = messageProp.stringValue(from: error)

/// Get request method: POST, PUT, DELETE, et cetera
let requestMethod = requestMethodProp.stringValue(from: error)

/// Get request URL (OData request)
let requestURL = requestURLProp.stringValue(from: error)

/// Use the values

The sample below shows how to access ErrorArchive using the built-in proxy class OfflineODataErrorArchiveEntity.

/// Get ErrorArchive entities. The type of the result is Array<OfflineODataErrorArchiveEntity>
try errorArchiveEntities = try eventService.fetchErrorArchive()

/// Access the entities (if some errors have occurred)
for error in errorArchiveEntities {
    let requestID = error.requestID
    let requestBody = error.requestBody ?? ""

    /// Use the values

Note that property names from the proxy class are slightly different from what you use in the dynamic API. For example, when using the dynamic API, you can access a property named RequestID. When using the proxy class, the property name is requestID.

Last update: October 30, 2020