I am stumped!
In my self-hosted medplum environment, I have a Bot which posts some data to a stand-alone service. Among the data it posts is it's own baseUrl and accessToken, so the service can retrieve some additional data.
The bot receives an Observation, which has an associated DocumentReference, and posts the Observation, along with the previously mentioned baseUrl and accessToken, over to the standalone service.
In the standalone service I plan to use @medplum/core to retrieve some additional information, utilizing the baseUrl and accessToken provided. However there is a problem.
In code, using that accessToken and baseUrl, I am able to successfully retrieve the Patient (e.g. medplum.get('/fhir/R4/Patient/
')), but I am not able to retrieve the DocumentReference (e.g. medplum.get('/fhir/R4/DocumentReference/
'). It always fails with 'Not Found'.
However, if I ssh into the container where that service is running and use the medplum cli (e.g. medplum --base-url
--access-token
get DocumentReference/
) then I am able to retrieve the DocumentReference resource.
The access token is retrieved in the Bot with "client.accessToken" and, as mentioned, can be used in code to retrieve the Patient associated with the Observation. The same accessToken can be used with the medplum cli to retrieve the DocumentReference in question - just not in code.
What gives?
This has been my whole day trying to figure this out. I appreciate any input.