A006 502 Bad Gateway - 405 without Allow Header

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