API Error Handling


HTTP Response Codes


This specification makes rules about the use of specific HTTP status codes in particular circumstances where the status codes SHALL map to particular states correctly, and only where the correct status code is not obvious. Other HTTP status codes may be used for other states as appropriate, and this particularly includes various authentication related status codes and redirects. Authentication redirects should not be interpreted to change the location of the resource itself.

FHIR® defines an OperationOutcome resource that can be used to convey specific detailed processable error information. For a few combinations of interactions and specific return codes, an OperationOutcome is required to be returned as the content of the response. The OperationOutcome may be returned with any HTTP 4xx or 5xx response, but is not required - many of these errors may be generated by generic server frameworks underlying a FHIR® server.

Gateway HTTP Response Codes


Table: Gateway HTTP Response Codes

HTTP Status Scenario Description
200 OK This indicates that the submitted request is valid
400 Bad Request This indicates that the submitted request is invalid. For example, the URL is malformed, the query parameters are badly formatted or do not match the required data type. Typically, this indicates an error with the software design of the client system, but in cases where the client does not validate inputs (e.g. dates) before submission, it is possible that allowing the user to correct search parameters could result in a successful response.
401 Unauthorized Indicates the request has been made without the appropriate authorization token. This should only occur if the authorization token in use has expired - as no system should make a query without having an authorization token in place.
404 Not found This will only be returned in the event of a specified resource does not exist.
405 Method Not Allowed A request method is not supported for the requested resource; for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.
429 Too Many Requests Rate limit
500 Internal Server Error Indicates that the server encountered an Internal error during the process of response message

In all the cases above except for the successful authorization, Gateway will respond with appropriate FHIR response to the client using an OperationOutcome Resource (Ref. http://hl7.org/fhir/R4/operationoutcome.html).

OperationOutcome resource


Operation outcomes are sets of error, warning and information messages that provide detailed information about the outcome of an attempted system operation.

This is the resource content:

idΣ0..1id
metaΣ0..1Meta
implicitRulesΣ ?!0..1uri
language0..1codeBinding
textI0..1Narrative
containedI0..*Resource
extensionI0..*Extension
modifierExtensionΣ ?! I0..*Extension
id0..1string
extensionI0..*Extension
modifierExtensionΣ ?! I0..*Extension
severityΣ1..1codeBinding
codeΣ1..1codeBinding
id0..1string
extensionI0..*Extension
id0..1string
extensionI0..*Extension
systemΣ1..1uri
versionΣ0..0string
codeΣ I1..1code
displayΣ I0..0string
userSelectedΣ0..0boolean
textΣ1..1string
diagnosticsΣ0..0string
locationΣ0..0string
expressionΣ0..0string

There are 2 types of error responses exposed by OperationOutcome resource: business and framework level errors.

Error Type Example
Business OperationOutcome
Framework level OperationOutcome
Multiple framework levels OperationOutcome

Framework Level Errors


This project's FHIR server is built using .NET SDK.

Legend
code = OperationOutcome.issue.code
severity = OperationOutcome.issue.severity
details.coding.code=OperationOutcome.issue.details.coding.code
details.coding.display=OperationOutcome.issue.details.coding.display
details.text = OperationOutcome.issue.details.coding.text
diagnostics = OperationOutcome.issue.diagnostics
severity code details.coding.code details.text
Error Invalid 1000 Element must not be empty
Error Invalid 1001 Encountered unknown child elements for definition ''
Error Invalid 1003 Type specified in the instance ('') is not one of the allowed choices ()
Error Invalid 1004 Conent element must match type
Error Invalid 1005 Value '' is too long (maximum length is )
Error Invalid 1006 Value '' does not match regex ''
Error Invalid 1008 Value is not exactly equal to fixed value '{toReadable(fixedValue)}'
Error Invalid 1009 Value does not match pattern '{toReadable(pattern)}'
Error Invalid 1010 Cannot determine the data type of this instance.
Error Invalid 1011 Instance indicates the element is of type '', which is not a known FHIR core type.
Error Invariant 1012 Instance failed constraint
Warning Invariant 1013 Instance failed constraint
Error Invalid 1015 Encountered a reference () of kind '' which is not allowed
Error Invalid 1016 Contained reference () is not resolvable
Error Invalid 1017 Encountered an unparseable reference ()
Warning Invalid 1018 Content reference not resolvable
Error Invalid 1019 Instance value '' is ''
Error Invalid 1020 Instance value '' is ''
Warning Invalid 1021 Content element primitive value not comparable
Error Invalid 1022 The stated profiles are constraints on multiple different core types (), which can never be satisfied.
Error Invalid 1023 Content invalid for required binding
Warning Invalid 1024 Content invalid for non required binding
Information Invalid 1025 Validation of binding with non-bindable instance type '' always succeeds.
Error Invalid 1026 Element does not match any slice, but the group at '' is closed.
Error Invalid 1027 Element matches slice '', but this is out of order for group '', since a previous element already matched slice '{ChildSlices[overallLastMatchingSlice].Name}'
Error Invalid 1028 Instance count for '' is , which is not within the specified cardinality of {Cardinality.ToString()}
Error Invalid 1029 Content element name does not match definition
Warning Informational 1030 Content reference cycle detected
Error Invalid 1100 .NET Xsd validation :
Warning Invalid 1101 .NET Xsd validation :
Error Invalid 1102 Parsing of Xml into a FHIR Poco failed:
Warning BusinessRule 2000 was given in ElementDefinition, but type '' is not an ordered type
Warning BusinessRule 2001 Unordered type
Warning BusinessRule 2002 MaxLength was given in ElementDefinition, but it has a negative value ()
Warning BusinessRule 2003 ElementDefinition contains a type with an empty type code
Warning BusinessRule 2004 Element has neither a type nor a nameReference.
Warning BusinessRule 2006 ElementDefinition uses a non-existing nameReference ''
Warning BusinessRule 2007 Element definition does not specify a 'min' value, which is required. Cardinality has not been validated
Warning BusinessRule 2008 Snapshot component of profile '{definition.StructureDefinition?.Url}' has no content.
Warning BusinessRule 2009 Evaluation of FhirPath for constraint '' failed:
Warning Incomplete 2010 There are no profile and type assertions at this point in the instance, so validation cannot succeed
Warning BusinessRule 2012 Incorrect binding spec
Warning Incomplete 2011 Encountered a binding element without a binding strength
Warning Structure 2013 Element matches both slice '{ChildSlices[lastMatchingSlide].Name}' and '{ChildSlices[sliceNumber].Name}', which signals a problem with the slice definition. This may result in spurious validation messages for this element.
Warning NotSupported 3000 Unsupported slicing
Warning Incomplete 3003 Encountered an invariant () that has no FhirPath expression, skipping validation of this constraint
Warning NotSupported 3004 Comparing the instance against the failed:
Warning NotSupported 3006 Unsupported binding
Error Incomplete 4000 Unable to resolve reference to profile ''
Error Incomplete 4002 Profile '' does not include a snapshot.
Error Incomplete 4003 The resolved external profile with url '' has no snapshot.
Error Incomplete 4004 The resolved external profile with url '' has no differential.
Warning Incomplete 4005 Resolution of external reference failed. Message:
Error Incomplete 4007 Cannot resolve binding references since neither TerminologyService nor ResourceResolver is given in the settings
Error Incomplete 4008 Unavailable validate code failed
Warning Incomplete 4009 Unable to resolve reference to profile ''
Information Informational 5000 Start validation of ElementDefinition at path '{definition.CanonicalPath()}'
Information Informational 5002 Starting validation of referenced resource ()
Fatal Exception 5003 Internal logic failure:
Error Informational 5004 Validation of this resource has been performed before with a failure result.
Error CodeInvalid 6001 Terminology code not in valueset
Error CodeInvalid 6002 Terminology abstract code not allowed
Warning CodeInvalid 6003 Terminology incorrect display
Warning NotSupported 6004 Terminology service failed while validating the codes:
Error CodeInvalid 6005 Extensible binding requires code or text.
Warning Informational 6006 Terminology output warning
Error CodeInvalid 6007 Terminology output error

Refer to the section "Business Level Errors" in each operation's documentation for business level errors:

  • Command 'pagelink' could not render: Page not found.
  • Command 'pagelink' could not render: Page not found.
  • Command 'pagelink' could not render: Page not found.