This line of code fails:
var uploadResult = await fhirClient.CreateAsync(binary);
With an error:
Hl7.Fhir.Rest.FhirOperationException: 'Operation was unsuccessful because of a client error (UnsupportedMediaType).
However, the output of binary.ToJson() is:
{
"resourceType": "Binary",
"contentType": "application/pdf",
"data": "H4sIAAAAAAAEAOy7V4vE3NYm9le....."}
Which works perfectly if I post using Postman.
Any ideas why my FhirClient fails?
If you are using dotnet it may be that the fhirClient expects the data field to be a byte array, and performs the conversion to base64 "under the hood" within the CreateAsync method. Here is a working example:
The result is available at http://hapi.fhir.org/baseR4/Binary/<result.Id>
Appendix
My *.csproj file looks like this: