index

Virk.dk REST API Response

The status of a request is always given in the response header as a HTTP status code.

If the status code signals error an additional error structure may be returned in the body of the response.

HTTP Status Codes used

Status Code Status Description
200 OK The request has succeeded. Note that 201 is used for a POST request success.
201 Created The request has been fulfilled and resulted in a new resource being created. The url for the resource created will be returned in the Location Header. If GET is implemented for the resource type, the ressouce can be read from the url using GET. Data tht can identify the resource created will also be returned in the body. The exact information returne din the body may vary.
400 Bad Request The request could not be understood by the service. Reason could be that a POST request cannot complete because the ressouce already exist. Or the input is of the wrong datatypes, ie. sending characters instead of numbers.
401 Unauthorized The request requires user authentication and either no certificate has been presented or the certificate cannot be validated. For furher information about certificates refer to Security - how to access resources
403 Forbidden Certificate has been validated but requester has not been granted rights to access the resource. For further information about access rights for resources refer to Security - how to access resources
404 Not Found The specified resource could not be found. Note: the resource might exist but the GET method might not be implemented for the resource type or the format requested might not be supported.
422 Unprocessable Entity The request could not be validated. Validation errors will be returned in a map in the response body as described in Error structure in response body
500 Internal Server Error The service encountered an unexpected condition which prevented it from fulfilling the request. Detailed information might be returned in the response body, refer ti Error structure in response body.

Error structure in response body

In some situations when a HTTP error status is returned the body will contain an additional error structure that might contain additional information about the error. Whether or not a body is returned depends on where the error condition occur.

Field Description
code HTTP Status Code (also returned in HTTP header)
status HTTP Status (also returned in HTTP header)
message Short description of the error
details More detailed description and/or data for the error if any can be provided. Can be a text or a structure with detailed data for the error condition, for instance a list of validation errors (se example below)

JSON example for an internal error

{
   "code":500
   "status":"Internal Server Error",
   "message":"Error when creating event",
   "details":"No details available",
}

JSON example for a not found

{
   "code":404
   "status":"Not Found",
   "message":"No Events was found",
   "details":"No Events for your authority exist",
}

JSON example for validation errors

{
       "code":"400",
       "status":"Bad Request",
       "message":"Validation failed",
       "details":{"uuid":"[uuid] skal angives",
                  "title":"[title] skal angives",
                  "description":"Besked feltet skal udfyldes",
                  "startDate":"[startDate] skal angives",
                  "recipientsType":"[recipientsType] skal angives"}}
}