PUT DocumentReference request to Epic FHIR Sandbox gets 404

I’m an engineer working to integrate some of my employer’s products with Epic’s FHIR APIs, on behalf of our clients who use Epic as their EHR.

At the moment, I’m querying Epic’s sandbox to prototype a feature that relies on creating and updating DocumentReferences, but I’m running into an issue when updating.. The relevant Epic documentation is here: https://fhir.epic.com/Specifications?api=10051

I first use the key and non-prod client ID associated with my Epic app (which has all R4 DocumentReference endpoints selected) to get an access token with scopes that include system/DocumentReference.read and system/DocumentReference.write.

I then create a DocumentReference with a POST request to https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/DocumentReference and receive a 201 Created response that includes the header “Location: DocumentReference/e6n4VrXC-RwUMrLSn-XKIQQ3”.

Using the ID from that header, I can then retrieve the DocumentReference just created with a GET request.

However, when I attempt to update this DocumentReference with a PUT request to the same URL (passing the returned resource as the body, modifying only its date or content.attachment values), I get the following error:

404 Not Found

{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "fatal",
      "code": "not-found",
      "details": {
        "coding": [
          {
            "system": "urn:oid:1.2.840.114350.1.13.0.1.7.2.657369",
            "code": "59009",
            "display": "The FHIR ID provided was not found."
          }
        ],
        "text": "The FHIR ID provided was not found."
      },
      "diagnostics": "Invalid FHIR ID provided",
      "location": ["/f:id"],
      "expression": ["id"]
    }
  ]
}

At the end of this post, I’ve included a Bash log demonstrating the requests I’m making and the responses I’m seeing, just skipping the access token request and redacting the token and cookies.

I’ve reached out to Epic support at [email protected], but if anyone here could help identify what’s going wrong, I’d appreciate your help!

Bash log

% curl -v --request POST 
  --url https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/DocumentReference 
  --header 'Accept: application/fhir+json' 
  --header 'Authorization: Bearer TOKEN_REDACTED' 
  --header 'Content-Type: application/json' 
  --cookie 'EpicPersistenceCookie=COOKIE_REDACTED' 
  --data '{
  "resourceType": "DocumentReference",
  "docStatus": "preliminary",
  "type": {
    "coding": [
      {
        "system": "http://loinc.org",
        "code": "11506-3",
        "display": "Progress Note"
      },
      {
        "system": "urn:oid:1.2.840.114350.1.13.0.1.7.4.737880.5010",
        "code": "1",
        "display": "Progress Note"
      }
    ],
    "text": "Progress Note"
  },
  "subject": {
    "reference": "/Patient/e63wRTbPfr1p8UW81d8Seiw3",
    "display": "Mr. Theodore Mychart"
  },
  "content": [
    {
      "attachment": {
        "contentType": "text/plain",
        "data": "MjAyNC0wOC0xMlQxNzoxMTozMS43ODVaIC0gUGF0aWVudCB3YXRjaGVkIFBhdGllbnQgRWR1Y2F0aW9uIHZpZGVvIHdpdGggSUQgMTIzNDU2LCAiQWZ0ZXIgeW91ciBoaXAgcmVwbGFjZW1lbnQiLCBmcm9tIDA6MDAgdG8gMjoxNSAoNzUlIGNvbXBsZXRlKQ=="
      }
    }
  ],
  "category": [{
    "coding": [
      {
        "system": "http://open.epic.com/FHIR/StructureDefinition/documentreferencecategory",
        "code": "document-information",
        "display": "Document Information"
      }
    ],
    "text": "Document Information"
  }],
  "context": {
    "encounter": [{ "reference": "/Encounter/ecgXt3jVqNNpsXnNXZ3KljA3" }]
  }
}'

Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 199.204.57.33:443...
* Connected to fhir.epic.com (199.204.57.33) port 443 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  subject: C=US; ST=Wisconsin; L=Verona; O=Epic Systems Corporation; CN=fhir.epic.com
*  start date: Nov 16 00:00:00 2023 GMT
*  expire date: Dec 16 23:59:59 2024 GMT
*  subjectAltName: host "fhir.epic.com" matched cert's "fhir.epic.com"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert Global G2 TLS RSA SHA256 2020 CA1
*  SSL certificate verify ok.
* using HTTP/1.x
> POST /interconnect-fhir-oauth/api/FHIR/R4/DocumentReference HTTP/1.1
> Host: fhir.epic.com
> User-Agent: curl/8.1.2
> Cookie: EpicPersistenceCookie=COOKIE_REDACTED
> Accept: application/fhir+json
> Authorization: Bearer TOKEN_REDACTED
> Content-Type: application/json
> Content-Length: 1185
>
< HTTP/1.1 201 Created
< Cache-Control: no-cache,no-store
< Pragma: no-cache
< Content-Type: application/fhir+json; charset=utf-8
< Expires: -1
< Location: DocumentReference/e6n4VrXC-RwUMrLSn-XKIQQ3
< ServerMetrics: {"BlockReads":521,"BlockWrites":1,"BlocksAllocated":1,"DBTime":310,"DatabaseCPUTime":72,"ECFNetworkTime":2,"ECFRequestCount":1,"ECFRequestTime":312,"GREF":8543,"JournalEntries":8,"LockWait":0.465,"LocksFailed":0,"LocksGranted":0,"MCommands":199858,"MemoryDifference":0,"NetworkCacheMisses":0,"NetworkUpdates":0,"WorkflowEventBlockReads":521,"WorkflowEventDBTime":310,"WorkflowEventECFNetworkTime":1,"WorkflowEventECFRequestCount":1,"WorkflowEventGREF":8543}
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Access-Control-Allow-Headers: origin, authorization, accept, content-type, x-requested-with, prefer, Epic-User-ID, Epic-User-IDType, Epic-Client-ID, soapaction, Epic-MyChartUser-ID, Epic-MyChartUser-IDType
< Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Date: Thu, 15 Aug 2024 19:45:20 GMT
< Content-Length: 0
< Set-Cookie: EpicPersistenceCookie=!inhCDhLEIDOf5MnJPAXLMgv89DqeopJ219gMS6Y85HU0KZqri9EDPUSafIBOjYzLke662iyrUqpMz04=; path=/; Httponly; Secure
<
* Connection #0 to host fhir.epic.com left intact


% curl --request GET 
  --url https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/DocumentReference/e6n4VrXC-RwUMrLSn-XKIQQ3 
  --header 'Accept: application/fhir+json' 
  --header 'Authorization: Bearer TOKEN_REDACTED' 
  --cookie 'EpicPersistenceCookie=COOKIE_REDACTED'

  {"resourceType":"DocumentReference","id":"e6n4VrXC-RwUMrLSn-XKIQQ3","identifier":[{"system":"urn:oid:1.2.840.114350.1.13.0.1.7.2.727879","value":"228688"},{"system":"urn:oid:1.2.840.114350.1.72.3.15","value":"1.2.840.114350.1.13.0.1.7.2.727879_228688"}],"status":"current","docStatus":"preliminary","type":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.0.1.7.4.737880.5010","code":"1","display":"Progress Notes"},{"system":"urn:oid:1.2.840.114350.1.72.727879.69848980","code":"1","display":"Progress Notes"},{"system":"http://loinc.org","code":"11506-3","display":"Progress note","userSelected":true}],"text":"Progress Notes"},"category":[{"coding":[{"system":"http://hl7.org/fhir/us/core/CodeSystem/us-core-documentreference-category","code":"clinical-note","display":"Clinical Note"}],"text":"Clinical Note"}],"subject":{"reference":"Patient/e63wRTbPfr1p8UW81d8Seiw3","display":"Mychart, Theodore"},"date":"2024-08-15T19:45:20Z","author":[{"reference":"Practitioner/evNp-KhYwOOqAZn1pZ2enuA3","type":"Practitioner","display":"User Interconnect"}],"custodian":{"identifier":{"system":"urn:ietf:rfc:3986","value":"urn:oid:fhir"},"display":"Epic USCDI on FHIR"},"content":[{"attachment":{"contentType":"text/html","url":"Binary/edbhZ.X8-cBPlRnIj22icLA3"},"format":{"system":"http://ihe.net/fhir/ValueSet/IHE.FormatCode.codesystem","code":"urn:ihe:iti:xds:2017:mimeTypeSufficient","display":"mimeType Sufficient"}},{"attachment":{"contentType":"text/rtf","url":"Binary/fkx4OEncZHlZpr4iwt6W84G2NofsNV7hrzaqszZ7i3Ik4"},"format":{"system":"http://ihe.net/fhir/ValueSet/IHE.FormatCode.codesystem","code":"urn:ihe:iti:xds:2017:mimeTypeSufficient","display":"mimeType Sufficient"}}],"context":{"extension":[{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.0.1.7.4.836982.1040","code":"3","display":"Registered Nurse"}],"text":"Registered Nurse"},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/clinical-note-author-provider-type"}],"encounter":[{"reference":"Encounter/ecgXt3jVqNNpsXnNXZ3KljA3","identifier":{"use":"usual","system":"urn:oid:1.2.840.114350.1.13.0.1.7.3.698084.8","value":"1853"},"display":"Office Visit"}],"period":{"start":"2013-11-06T20:45:00Z"}}}


% curl -v --request PUT 
  --url https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4/DocumentReference/e6n4VrXC-RwUMrLSn-XKIQQ3 
  --header 'Accept: application/fhir+json' 
  --header 'Authorization: Bearer TOKEN_REDACTED' 
  --header 'Content-Type: application/json' 
  --cookie 'EpicPersistenceCookie=COOKIE_REDACTED' 
  --data '{
  "resourceType": "DocumentReference",
  "id": "e6n4VrXC-RwUMrLSn-XKIQQ3",
  "identifier": [
    {
      "system": "urn:oid:1.2.840.114350.1.13.0.1.7.2.727879",
      "value": "228688"
    },
    {
      "system": "urn:oid:1.2.840.114350.1.72.3.15",
      "value": "1.2.840.114350.1.13.0.1.7.2.727879_228688"
    }
  ],
  "status": "current",
  "docStatus": "preliminary",
  "type": {
    "coding": [
      {
        "system": "urn:oid:1.2.840.114350.1.13.0.1.7.4.737880.5010",
        "code": "1",
        "display": "Progress Notes"
      },
      {
        "system": "urn:oid:1.2.840.114350.1.72.727879.69848980",
        "code": "1",
        "display": "Progress Notes"
      },
      {
        "system": "http://loinc.org",
        "code": "11506-3",
        "display": "Progress note",
        "userSelected": true
      }
    ],
    "text": "Progress Notes"
  },
  "category": [
    {
      "coding": [
        {
          "system": "http://hl7.org/fhir/us/core/CodeSystem/us-core-documentreference-category",
          "code": "clinical-note",
          "display": "Clinical Note"
        }
      ],
      "text": "Clinical Note"
    }
  ],
  "subject": {
    "reference": "Patient/e63wRTbPfr1p8UW81d8Seiw3",
    "display": "Mychart, Theodore"
  },
  "date": "2024-08-15T19:46:00Z",
  "author": [
    {
      "reference": "Practitioner/evNp-KhYwOOqAZn1pZ2enuA3",
      "type": "Practitioner",
      "display": "User Interconnect"
    }
  ],
  "custodian": {
    "identifier": {
      "system": "urn:ietf:rfc:3986",
      "value": "urn:oid:fhir"
    },
    "display": "Epic USCDI on FHIR"
  },
  "content": [
    {
      "attachment": {
        "contentType": "text/html",
        "url": "Binary/edbhZ.X8-cBPlRnIj22icLA3"
      },
      "format": {
        "system": "http://ihe.net/fhir/ValueSet/IHE.FormatCode.codesystem",
        "code": "urn:ihe:iti:xds:2017:mimeTypeSufficient",
        "display": "mimeType Sufficient"
      }
    },
    {
      "attachment": {
        "contentType": "text/rtf",
        "url": "Binary/fkx4OEncZHlZpr4iwt6W84G2NofsNV7hrzaqszZ7i3Ik4"
      },
      "format": {
        "system": "http://ihe.net/fhir/ValueSet/IHE.FormatCode.codesystem",
        "code": "urn:ihe:iti:xds:2017:mimeTypeSufficient",
        "display": "mimeType Sufficient"
      }
    }
  ],
  "context": {
    "extension": [
      {
        "valueCodeableConcept": {
          "coding": [
            {
              "system": "urn:oid:1.2.840.114350.1.13.0.1.7.4.836982.1040",
              "code": "3",
              "display": "Registered Nurse"
            }
          ],
          "text": "Registered Nurse"
        },
        "url": "http://open.epic.com/FHIR/StructureDefinition/extension/clinical-note-author-provider-type"
      }
    ],
    "encounter": [
      {
        "reference": "Encounter/ecgXt3jVqNNpsXnNXZ3KljA3",
        "identifier": {
          "use": "usual",
          "system": "urn:oid:1.2.840.114350.1.13.0.1.7.3.698084.8",
          "value": "1853"
        },
        "display": "Office Visit"
      }
    ],
    "period": {
      "start": "2013-11-06T20:45:00Z"
    }
  }
}'

*   Trying 199.204.57.33:443...
* Connected to fhir.epic.com (199.204.57.33) port 443 (#0)
* ALPN: offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  subject: C=US; ST=Wisconsin; L=Verona; O=Epic Systems Corporation; CN=fhir.epic.com
*  start date: Nov 16 00:00:00 2023 GMT
*  expire date: Dec 16 23:59:59 2024 GMT
*  subjectAltName: host "fhir.epic.com" matched cert's "fhir.epic.com"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert Global G2 TLS RSA SHA256 2020 CA1
*  SSL certificate verify ok.
* using HTTP/1.x
> PUT /interconnect-fhir-oauth/api/FHIR/R4/DocumentReference/e6n4VrXC-RwUMrLSn-XKIQQ3 HTTP/1.1
> Host: fhir.epic.com
> User-Agent: curl/8.1.2
> Cookie: EpicPersistenceCookie=COOKIE_REDACTED
> Accept: application/fhir+json
> Authorization: Bearer TOKEN_REDACTED
> Content-Type: application/json
> Content-Length: 2755
>
< HTTP/1.1 404 Not Found
< Cache-Control: no-cache,no-store
< Pragma: no-cache
< Content-Length: 354
< Content-Type: application/fhir+json; charset=utf-8
< Expires: -1
< ServerMetrics: {"BlockReads":0,"BlockWrites":0,"BlocksAllocated":0,"DBTime":21,"DatabaseCPUTime":23,"ECFNetworkTime":2,"ECFRequestCount":1,"ECFRequestTime":23,"GREF":897,"JournalEntries":0,"LockWait":0,"LocksFailed":0,"LocksGranted":0,"MCommands":69108,"MemoryDifference":0,"NetworkCacheMisses":0,"NetworkUpdates":0,"WorkflowEventBlockReads":0,"WorkflowEventDBTime":21,"WorkflowEventECFNetworkTime":1,"WorkflowEventECFRequestCount":1,"WorkflowEventGREF":897}
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Access-Control-Allow-Headers: origin, authorization, accept, content-type, x-requested-with, prefer, Epic-User-ID, Epic-User-IDType, Epic-Client-ID, soapaction, Epic-MyChartUser-ID, Epic-MyChartUser-IDType
< Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Date: Thu, 15 Aug 2024 19:51:56 GMT
< Set-Cookie: EpicPersistenceCookie=!wbamofpZSJTD5PDJPAXLMgv89DqeolqKXNX/juNhvACXwUQ62yaq+xlXoJNaTO5xij5CC8sbnan8RCY=; path=/; Httponly; Secure
<
* Connection #0 to host fhir.epic.com left intact
{"resourceType":"OperationOutcome","issue":[{"severity":"fatal","code":"not-found","details":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.0.1.7.2.657369","code":"59009","display":"The FHIR ID provided was not found."}],"text":"The FHIR ID provided was not found."},"diagnostics":"Invalid FHIR ID provided","location":["/f:id"],"expression":["id"]}]}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật