A006 502 Bad Gateway - 405 without Allow Header

Hi Team,

We are having issues trying to download attachments for a test referral using the A006 Endpoint, I am getting 502 responses with a fault string of “Received 405 Response without Allow Header”.
My understanding from historical posts on this forum is that this happens when we try and call an endpoint with the wrong HTTP method but I am sure that I am sending a GET request.
The details of my request are as follows:
Access Mode: Application-Restricted Access.
Authorisation: Bearer Token, used successfully moments ago to get AttachmentIDs.
Accept: “/” to ensure whatever the attachment type we accept it.
X-Correlation-ID: “TEST_A006_UUID”
Request Paths: “https://int.api.service.nhs.uk/referrals/FHIR/STU3/Binary/#DocumentReference-118590” & “https://int.api.service.nhs.uk/referrals/FHIR/STU3/Binary/#DocumentReference-118592
Can you advise what our issue is here?

Many Thanks,
Dave

EDIT:
In light of the email that went out from eRS Partners this morning about the upcoming deprecation of the A006 endpoint and release of the new A042 endpoint I would like to extend my query to cover that new endpoint to ask whether we can expect this issue to continue when moving to using A042 to retrieve attachments and if more descriptive error handling has been implemented for the new endpoint?

Hi @david.plummer,

It looks like the request path you are forming isn’t quite correct and due to this we aren’t actually seeing the part after the final /. So the server thinks you are attempting to GET from /Binary which isn’t supported (only POST is). (As discussed in other posts we have an issue on our side where we are not including the Accept header on the 405 response - leading to the error you are seeing).

The good news is that it should be simple to fix the way you are forming the request path. This approach will work for the existing legacy (A006) and new (A042) download APIs.

Documents attached to a ReferralRequest are included in the supportingInfo section. The # in these references indicate in FHIR that the related resource is “contained” (see Contained Resources).

You will find the referenced DocumentReference resource in the ReferralRequest.contained array, searching by the id.

The DocumentReference resource contains all the metadata about the associated document. Here is an example of a DocumentReference:

{
    "id": "DocumentReference-80000",
    "resourceType": "DocumentReference",
    "meta": {
        "profile": [
            "https://fhir.nhs.uk/STU3/StructureDefinition/eRS-DocumentReference-1"
        ]
    },
    "status": "current",
    "description": "referralletter pdf",
    "indexed": "2021-06-11T12:09:09.459Z",
    "type": {
        "coding": [
            {
                "code": "REFERRER",
                "display": "Referrer",
                "system": "https://fhir.nhs.uk/STU3/CodeSystem/eRS-AttachmentType-1"
            }
        ]
    },
    "content": [
        {
            "attachment": {
                "contentType": "application/pdf",
                "creation": "2021-06-11",
                "extension": [
                    {
                        "url": "https://fhir.nhs.uk/STU3/StructureDefinition/Extension-eRS-AttachedBy-1",
                        "valueReference": {
                            "identifier": {
                                "system": "http://fhir.nhs.net/Id/sds-user-id",
                                "value": "021600556514"
                            }
                        }
                    }
                ],
                "id": "80000",
                "size": 6,
                "title": "referralletter.pdf",
                "url": "Binary/719f6045-e791-4029-8e0f-1201c02b0a55"
            }
        }
    ]
}

You can construct the request path to download a document/attachment by joining the following:

Request Path = Base Path + Document URL (i.e. https://int.api.service.nhs.uk/referrals/FHIR/STU3/Binary/719f6045-e791-4029-8e0f-1201c02b0a55

I hope this answers your questions and resolves your issues.

Regards,

Adam.

2 Likes