I have an azure function which makes a call to the FHIR service. Code is as follows.
var resultBundle = await fhirClient.OperationAsync(
operation: new Uri($"{_config.GetValue<string>($"FhirServerUrl")}/Location/$getAllLocationsForFacility?coid={request.coid}&status=active"),
useGet: true) as Bundle;
While executing this line, I am getting the below error.
Executed 'Azure_Function_FunctionName' (Failed, Id=73423f7676-68d9-809d-s998-87867676969, Duration=21130ms)
[2024-02-26T07:10:35.843Z] System.Private.CoreLib: Exception while executing function: Azure_Function_FunctionName. Hl7.Fhir.DSTU2.Core: Operation was unsuccessful because of a client error (NotAcceptable). OperationOutcome: Overall result: FAILURE (1 errors and 0 warnings)
[2024-02-26T07:10:35.847Z]
[2024-02-26T07:10:35.848Z] [ERROR] (no details)(further diagnostics: Value supplied for the "Accept" header is not supported.).
I have searched for FHIR documentation for dotnet. But I am not seeing any defeniction for fhirClient.OperationAsync() method? Any idea about this method and the error message?
The FhirClient.OperationAsync will send an HTTP request to the FHIR server to request the execution of the specified operation (getAllLocationsForFacility). The details of the HTTP call, such as the Content-Type and mimetype that is Accepted for the response are set by the FhirClient.
In your case, the response indicates that the mime type value that is in the Accept header of the request is not supported by the server. This can have several reasons. Check what type the server can respond with, and use the FhirClient.PreferredFormat setting to set the Accept header accordingly.
Do check if you use the correct FHIR version in your code, because the Azure service apparently uses DSTU2 and the mime types for that are different from those in FHIR R4, which is currently the most widely used version.
There is some documentation about the FhirClient here: https://docs.fire.ly/projects/Firely-NET-SDK/en/latest/client.html, but no explanation about the operation calls. You can use the inline documentation in VS, or lookup the source code on GitHub: https://github.com/FirelyTeam/firely-net-sdk/